8000 [Cache] Handle unserialization failures for Memcached · symfony/symfony@cccc88f · GitHub
[go: up one dir, main page]

Skip to content

Commit cccc88f

Browse files
[Cache] Handle unserialization failures for Memcached
1 parent 34d5f9e commit cccc88f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ trait MemcachedTrait
2626
'persistent_id' => null,
2727
'username' => null,
2828
'password' => null,
29+
'serializer' => 'php',
2930
);
3031

3132
private $client;
@@ -194,7 +195,14 @@ protected function doSave(array $values, $lifetime)
194195
*/
195196
protected function doFetch(array $ids)
196197
{
197-
return $this->checkResultCode($this->client->getMulti($ids));
198+
$unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
199+
try {
200+
return $this->checkResultCode($this->client->getMulti($ids));
201+
} catch (\Error $e) {
202+
throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
203+
} finally {
204+
ini_set('unserialize_callback_func', $unserializeCallbackHandler);
205+
}
198206
}
199207

200208
/**

0 commit comments

Comments
 (0)
0