Skip to content

Commit

Permalink
bug #18243 Fixed a bug: saving with not serializable values (RedisAda…
Browse files Browse the repository at this point in the history
…pter) (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)
  • Loading branch information
nicolas-grekas committed Mar 21, 2016
2 parents 83ebf97 + 47f45b1 commit fd0ddfb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Symfony/Component/Cache/Adapter/RedisAdapter.php
Expand Up @@ -90,22 +90,23 @@ protected function doDelete(array $ids)
*/
protected function doSave(array $values, $lifetime)
{
$serialized = array();
$failed = array();

foreach ($values as $id => $v) {
try {
$values[$id] = serialize($v);
$serialized[$id] = serialize($v);
} catch (\Exception $e) {
$failed[] = $id;
}
}

if (!$this->redis->mSet($values)) {
if (!$this->redis->mSet($serialized)) {
return false;
}

if ($lifetime >= 1) {
foreach ($values as $id => $v) {
foreach ($serialized as $id => $v) {
$this->redis->expire($id, $lifetime);
}
}
Expand Down

0 comments on commit fd0ddfb

Please sign in to comment.