8000 bug #34668 [Cache] Make sure we get the correct number of values from… · symfony/symfony@f0a6de2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0a6de2

Browse files
bug #34668 [Cache] Make sure we get the correct number of values from redis::mget() (thePanz)
This PR was merged into the 3.4 branch. Discussion ---------- [Cache] Make sure we get the correct number of values from redis::mget() | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Redis might not be reachable when invoking `redis->mget($ids)`, the call returns `false` instead of an array. This change makes sure the return value is properly check, including the correctness of the parameters to invoke `array_combine($ids, $cacheValues);`. From the documentation: > Returns the combined array, FALSE if the number of elements for each array isn't equal. Commits ------- 685c36c [Cache] Make sure we get the correct number of values from redis::mget()
2 parents ed101fb + 685c36c commit f0a6de2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@ protected function doFetch(array $ids)
179179
}
180180
});
181181
} else {
182-
$values = array_combine($ids, $this->redis->mget($ids));
182+
$values = $this->redis->mget($ids);
183+
184+
if (!\is_array($values) || \count($values) !== \count($ids)) {
185+
return [];
186+
}
187+
188+
$values = array_combine($ids, $values);
183189
}
184190

185191
foreach ($values as $id => $v) {

0 commit comments

Comments
 (0)
0