Skip to content

Commit fd0ddfb

Browse files
bug #18243 Fixed a bug: saving with not serializable values (RedisAdapter) (masterklavi)
This PR was squashed before being merged into the 3.1-dev branch (closes #18243). Discussion ---------- Fixed a bug: saving with not serializable values (RedisAdapter) | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 47f45b1 Fixed a bug: saving with not serializable values (RedisAdapter)
2 parents 83ebf97 + 47f45b1 commit fd0ddfb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,23 @@ protected function doDelete(array $ids)
9090
*/
9191
protected function doSave(array $values, $lifetime)
9292
{
93+
$serialized = array();
9394
$failed = array();
9495

9596
foreach ($values as $id => $v) {
9697
try {
97-
$values[$id] = serialize($v);
98+
$serialized[$id] = serialize($v);
9899
} catch (\Exception $e) {
99100
$failed[] = $id;
100101
}
101102
}
102103

103-
if (!$this->redis->mSet($values)) {
104+
if (!$this->redis->mSet($serialized)) {
104105
return false;
105106
}
106107

107108
if ($lifetime >= 1) {
108-
foreach ($values as $id => $v) {
109+
foreach ($serialized as $id => $v) {
109110
$this->redis->expire($id, $lifetime);
110111
}
111112
}

0 commit comments

Comments
 (0)