8000 bug #40273 [Cache] fix setting items' metadata on commit() (nicolas-g… · symfony/symfony@0027d1c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0027d1c

Browse files
bug #40273 [Cache] fix setting items' metadata on commit() (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [Cache] fix setting items' metadata on commit() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36697 | License | MIT | Doc PR | - Commits ------- 9bb4b31 [Cache] fix setting items' metadata on commit()
2 parents 8054d1d + 9bb4b31 commit 0027d1c

15 files changed

+8
-13
lines changed

src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static function ($deferred, &$expiredIds) use ($getId, $tagPrefix, $defaultLifet
110110
}
111111

112112
$byLifetime[$ttl][$getId($key)] = $value;
113+
$item->metadata = $item->newMetadata;
113114
}
114115

115116
return $byLifetime;

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static function ($deferred) {
8383
$tagsByKey = [];
8484
foreach ($deferred as $key => $item) {
8585
$tagsByKey[$key] = $item->newMetadata[CacheItem::METADATA_TAGS] ?? [];
86+
$item->metadata = $item->newMetadata;
8687
}
8788

8889
return $tagsByKey;

src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
1716

1817
/**
1918
* @group time-sensitive

src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\PdoAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
1716

1817
/**
1918
* @group time-sensitive

src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Doctrine\DBAL\DriverManager;
1515
use Psr\Cache\CacheItemPoolInterface;
1616
use Symfony\Component\Cache\Adapter\PdoAdapter;
17-
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
1817

1918
/**
2019
* @group time-sensitive

src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php renamed to src/Symfony/Component/Cache/Tests/Adapter/PdoPruneableTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Cache\Tests\Traits;
12+
namespace Symfony\Component\Cache\Tests\Adapter;
1313

1414
trait PdoPruneableTrait
1515
{

src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
1716

1817
/**
1918
* @group integration

src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
1716

1817
/**
1918
* @group integration

src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
1716
use Symfony\Component\Cache\Traits\RedisProxy;
1817

1918
/**

src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
1716

1817
/**
1918
* @group integration

src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
16-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
1716
use Symfony\Component\Cache\Traits\RedisClusterProxy;
1817

1918
/**

src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
2020
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
2121
use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter;
22-
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
2322

2423
/**
2524
* @group time-sensitive

src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php renamed to src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Cache\Tests\Traits;
12+
namespace Symfony\Component\Cache\Tests\Adapter;
1313

1414
use Symfony\Component\Cache\CacheItem;
1515

@@ -150,7 +150,9 @@ public function testGetMetadata()
150150
$pool = $this->createCachePool();
151151

152152
$i = $pool->getItem('k');
153+
$this->assertSame([], $i->getMetadata());
153154
$pool->save($i->tag('foo'));
155+
$this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]);
154156

155157
$i = $pool->getItem('k');
156158
$this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]);

src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Psr\SimpleCache\CacheInterface;
1515
use Symfony\Component\Cache\Simple\PdoCache;
16-
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
16+
use Symfony\Component\Cache\Tests\Adapter\PdoPruneableTrait;
1717

1818
/**
1919
* @group time-sensitive

src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Doctrine\DBAL\DriverManager;
1515
use Psr\SimpleCache\CacheInterface;
1616
use Symfony\Component\Cache\Simple\PdoCache;
17-
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
17+
use Symfony\Component\Cache\Tests\Adapter\PdoPruneableTrait;
1818

1919
/**
2020
* @group time-sensitive

0 commit comments

Comments
 (0)
0