Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da8dfb9

Browse files
committed
[Cache] fix logic for fetching tag versions on TagAwareAdapter
1 parent 278f40f commit da8dfb9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,16 @@ private function getTagVersions(array $tagsByKey, array &$invalidatedTags = arra
344344
$tags = array();
345345
foreach ($tagVersions as $tag => $version) {
346346
$tags[$tag.static::TAGS_PREFIX] = $tag;
347-
if ($fetchTagVersions || !isset($this->knownTagVersions[$tag])) {
347+
348+
if ($fetchTagVersions) {
349+
continue;
350+
}
351+
352+
if (!isset($this->knownTagVersions[$tag])) {
353+
$fetchTagVersions = true;
348354
continue;
349355
}
356+
350357
$version -= $this->knownTagVersions[$tag][1];
351358
if ((0 !== $version && 1 !== $version) || $this->knownTagVersionsTtl > $now - $this->knownTagVersions[$tag][0]) {
352359
// reuse previously fetched tag versions up to the ttl, unless we are storing items or a potential miss arises

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ public function testInvalidateTags()
6969
$this->assertFalse($pool->getItem('i1')->isHit());
7070
$this->assertFalse($pool->getItem('i3')->isHit());
7171
$this->assertTrue($pool->getItem('foo')->isHit());
72+
73+
$anotherPoolInstance = $this->createCachePool();
74+
75+
$this->assertFalse($anotherPoolInstance->getItem('i1')->isHit());
76+
$this->assertFalse($anotherPoolInstance->getItem('i3')->isHit());
77+
$this->assertTrue($anotherPoolInstance->getItem('foo')->isHit());
7278
}
7379

7480
public function testInvalidateCommits()

0 commit comments

Comments
 (0)