Skip to content

Commit f68d816

Browse files
bug #53846 [Cache] Fix BC layer with pre-6.1 cache items (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [Cache] Fix BC layer with pre-6.1 cache items | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53825 | License | MIT Issue introduced in #42997 Commits ------- 9372d95 [Cache] Fix BC layer with pre-6.1 cache items
2 parents 5e44cfc + 9372d95 commit f68d816

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ public function getItems(array $keys = []): iterable
146146
foreach ($keys as $key) {
147147
if ('' !== $key && \is_string($key)) {
148148
$commit = $commit || isset($this->deferred[$key]);
149-
$key = static::TAGS_PREFIX.$key;
150-
$tagKeys[$key] = $key; // BC with pools populated before v6.1
151149
}
152150
}
153151

@@ -156,7 +154,7 @@ public function getItems(array $keys = []): iterable
156154
}
157155

158156
try {
159-
$items = $this->pool->getItems($tagKeys + $keys);
157+
$items = $this->pool->getItems($keys);
160158
} catch (InvalidArgumentException $e) {
161159
$this->pool->getItems($keys); // Should throw an exception
162160

@@ -166,18 +164,24 @@ public function getItems(array $keys = []): iterable
166164
$bufferedItems = $itemTags = [];
167165

168166
foreach ($items as $key => $item) {
169-
if (isset($tagKeys[$key])) { // BC with pools populated before v6.1
170-
if ($item->isHit()) {
171-
$itemTags[substr($key, \strlen(static::TAGS_PREFIX))] = $item->get() ?: [];
172-
}
173-
continue;
174-
}
175-
176167
if (null !== $tags = $item->getMetadata()[CacheItem::METADATA_TAGS] ?? null) {
177168
$itemTags[$key] = $tags;
178169
}
179170

180171
$bufferedItems[$key] = $item;
172+
173+
if (null === $tags) {
174+
$key = static::TAGS_PREFIX.$key;
175+
$tagKeys[$key] = $key; // BC with pools populated before v6.1
176+
}
177+
}
178+
179+
if ($tagKeys) {
180+
foreach ($this->pool->getItems($tagKeys) as $key => $item) {
181+
if ($item->isHit()) {
182+
$itemTags[substr($key, \strlen(static::TAGS_PREFIX))] = $item->get() ?: [];
183+
}
184+
}
181185
}
182186

183187
$tagVersions = $this->getTagVersions($itemTags, false);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy