8000 [Cache] Fix BC layer with pre-6.1 cache items · symfony/symfony@9372d95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9372d95

Browse files
[Cache] Fix BC layer with pre-6.1 cache items
1 parent 2868d0d commit 9372d95

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)
0