8000 [Cache] ignore unserialization failures in AbstractTagAwareAdapter::d… · symfony/symfony@a1f334c · GitHub
[go: up one dir, main page]

Skip to content

Commit a1f334c

Browse files
[Cache] ignore unserialization failures in AbstractTagAwareAdapter::doDelete()
1 parent 1292d8d commit a1f334c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,14 @@ public function deleteItems(array $keys)
229229
unset($this->deferred[$key]);
230230
}
231231

232-
foreach ($this->doFetch($ids) as $id => $value) {
233-
foreach ($value['tags'] ?? [] as $tag) {
234-
$tagData[$this->getId(self::TAGS_PREFIX.$tag)][] = $id;
232+
try {
233+
foreach ($this->doFetch($ids) as $id => $value) {
234+
foreach ($value['tags'] ?? [] as $tag) {
235+
$tagData[$this->getId(self::TAGS_PREFIX.$tag)][] = $id;
236+
}
235237
}
238+
} catch (\Exception $e) {
239+
// ignore unserialization failures
236240
}
237241

238242
try {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function doSave(array $values, ?int $lifetime, array $addTagData = [],
9797
}
9898

9999
// While pipeline isn't supported on RedisCluster, other setups will at least benefit from doing this in one op
100-
$results = $this->pipeline(static function () use ($serialized, $lifetime, $addTagData, $delTagData) {
100+
$results = $this->pipeline(static function () use ($serialized, $lifetime, $addTagData, $delTagData, $failed) {
101101
// Store cache items, force a ttl if none is set, as there is no MSETEX we need to set each one
102102
foreach ($serialized as $id => $value) {
103103
yield 'setEx' => [
@@ -109,11 +109,15 @@ protected function doSave(array $values, ?int $lifetime, array $addTagData = [],
109109

110110
// Add and Remove Tags
111111
foreach ($addTagData as $tagId => $ids) {
112-
yield 'sAdd' => array_merge([$tagId], $ids);
112+
if (!$failed || $ids = array_diff($ids, $failed)) {
113+
yield 'sAdd' => array_merge([$tagId], $ids);
114+
}
113115
}
114116

115117
foreach ($delTagData as $tagId => $ids) {
116-
yield 'sRem' => array_merge([$tagId], $ids);
118+
if (!$failed || $ids = array_diff($ids, $failed)) {
119+
yield 'sRem' => array_merge([$tagId], $ids);
120+
}
117121
}
118122
});
119123

0 commit comments

Comments
 (0)
0