Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fc9acad

Browse filesBrowse 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
Copy full SHA for fc9acad

File tree

1 file changed

+2
-9
lines changed
Filter options

1 file changed

+2
-9
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
+2-9Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.