Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8907bc4

Browse filesBrowse files
bug #23615 [Cache] Handle serialization failures for Memcached (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [Cache] Handle serialization failures for Memcached | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Fixes two issues with serialization + memcached: with the memcached extension, the default serializer is automatically selected as igbinary when possible, native php otherwise. That creates obvious migration/portability issues (ie just installing igbinary wipes out the value of your cache.) Then, handling unserializing failures (esp. "php_incomplete_class") is a paramount feature of the component. You must be able to deal with migrating you code base without being blocked by some legacy serialized data. Commits ------- cccc88f [Cache] Handle unserialization failures for Memcached
2 parents a00b05e + cccc88f commit 8907bc4
Copy full SHA for 8907bc4

File tree

Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/MemcachedTrait.php
+9-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.