Skip to content

Commit fa24fa8

Browse files
[Cache] Fix race condition in TagAwareAdapter
1 parent b87a395 commit fa24fa8

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)