8000 [Cache] Fix BC layer with pre-6.1 cache items by nicolas-grekas · Pull Request #53846 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Fix BC layer with pre-6.1 cache items #53846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ public function getItems(array $keys = []): iterable
foreach ($keys as $key) {
if ('' !== $key && \is_string($key)) {
$commit = $commit || isset($this->deferred[$key]);
$key = static::TAGS_PREFIX.$key;
$tagKeys[$key] = $key; // BC with pools populated before v6.1
}
}

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

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

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

foreach ($items as $key => $item) {
if (isset($tagKeys[$key])) { // BC with pools populated before v6.1
if ($item->isHit()) {
$itemTags[substr($key, \strlen(static::TAGS_PREFIX))] = $item->get() ?: [];
}
continue;
}

if (null !== $tags = $item->getMetadata()[CacheItem::METADATA_TAGS] ?? null) {
$itemTags[$key] = $tags;
}

$bufferedItems[$key] = $item;

if (null === $tags) {
$key = static::TAGS_PREFIX.$key;
$tagKeys[$key] = $key; // BC with pools populated before v6.1
}
}

if ($tagKeys) {
foreach ($this->pool->getItems($tagKeys) as $key => $item) {
if ($item->isHit()) {
$itemTags[substr($key, \strlen(static::TAGS_PREFIX))] = $item->get() ?: [];
}
}
}

$tagVersions = $this->getTagVersions($itemTags, false);
Expand Down
0