Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Cache] Handle unserialize() failures gracefully#19567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
2915a08 to1e151a6Compareb18a56f to448de93Compare| $isHit =false; | ||
| } | ||
| }catch (\Exception$e) { | ||
| CacheItem::log($this->logger,'Failed to unserialize key "{key}"',array('key' =>$key,'exception' =>$e)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It should not happen as this adapter is not cross requests (so something not unserializable won't be cached as it is not serializable as well).
If you want to keep this anyway then i guess you should useparent::unserialize below ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok got it it might break in case of a custom unserializer.
At least usingparent::unserialize would allow you to remove the case managingfalse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There is no parent here, and calling the same implementation would call ini_set twice for something that can't happen because as you said, this is not cross reqs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You're right sorry, i should definitely stop reviewing on my phone...
448de93 to5a8dbbeCompare| yield$key =>$f($key,$value,$isHit); | ||
| } | ||
| }catch (\Exception$e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Shouldn't this be moved inside the foreach to fetch as many values as possible ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
right, done: try/catch moved inside the foreach
GuilhemN commentedAug 9, 2016
LGTM 👍 |
20184d0 to69cfa83Compare69cfa83 to47db638Comparefabpot commentedAug 13, 2016
Thank you@nicolas-grekas. |
…grekas)This PR was merged into the 3.1 branch.Discussion----------[Cache] Handle unserialize() failures gracefully| Q | A| ------------- | ---| Branch? | 3.1| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -This makes fetching cached items more resilient: `__PHP_Incomplete_Class` "objects" and other errors triggered by unserialize should be turned to cache misses.Commits-------47db638 [Cache] Handle unserialize() failures gracefully
Uh oh!
There was an error while loading.Please reload this page.
This makes fetching cached items more resilient:
__PHP_Incomplete_Class"objects" and other errors triggered by unserialize should be turned to cache misses.