8000 bug #24419 [Cache] Fix race condition in TagAwareAdapter (nicolas-gre… · symfony/symfony@fc9acad · GitHub
[go: up one dir, main page]

Skip to content

Commit fc9acad

Browse files
committed
bug #24419 [Cache] Fix race condition in TagAwareAdapter (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [Cache] Fix race condition in TagAwareAdapter | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24240 | License | MIT | Doc PR | - This code is not needed, and might create a race condition (see linked issue). Let's drop it. When no tags are set on an item, this stores an empty tags array, instead of deleting the tags array entry at all. Commits ------- fa24fa8 [Cache] Fix race condition in TagAwareAdapter
2 parents 417ec3a + fa24fa8 commit fc9acad

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,12 @@ public function commit()
250250

251251
$f = $this->getTagsByKey;
252252
$tagsByKey = $f($items);
253-
$deletedTags = $this->deferred = array();
253+
$this->deferred = array();
254254
$tagVersions = $this->getTagVersions($tagsByKey);
255255
$f = $this->createCacheItem;
256256

257257
foreach ($tagsByKey as $key => $tags) {
258-
if ($tags) {
259-
$this->itemsAdapter->saveDeferred($f(static::TAGS_PREFIX.$key, array_intersect_key($tagVersions, $tags), $items[$key]));
260-
} else {
261-
$deletedTags[] = static::TAGS_PREFIX.$key;
262-
}
263-
}
264-
if ($deletedTags) {
265-
$this->itemsAdapter->deleteItems($deletedTags);
258+
$this->itemsAdapter->saveDeferred($f(static::TAGS_PREFIX.$key, array_intersect_key($tagVersions, $tags), $items[$key]));
266259
}
267260
}
268261

0 commit comments

Comments
 (0)
0