Skip to content

Commit

Permalink
[Cache] Handle unserialization failures for Memcached
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jul 23, 2017
1 parent 34d5f9e commit cccc88f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Symfony/Component/Cache/Traits/MemcachedTrait.php
Expand Up @@ -26,6 +26,7 @@ trait MemcachedTrait
'persistent_id' => null,
'username' => null,
'password' => null,
'serializer' => 'php',
);

private $client;
Expand Down Expand Up @@ -194,7 +195,14 @@ protected function doSave(array $values, $lifetime)
*/
protected function doFetch(array $ids)
{
return $this->checkResultCode($this->client->getMulti($ids));
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
try {
return $this->checkResultCode($this->client->getMulti($ids));
} catch (\Error $e) {
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
} finally {
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
}
}

/**
Expand Down

0 comments on commit cccc88f

Please sign in to comment.