-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Catch \Throwable in getCacheKey() #36336
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,20 @@ protected function createChildContext(array $parentContext, $attribute/*, string | |
private function getCacheKey($format, array $context) | ||
{ | ||
unset($context['cache_key']); // avoid artificially different keys | ||
|
||
if (interface_exists(\Throwable::class)) { | ||
try { | ||
return md5($format.serialize([ | ||
'context' => $context, | ||
'ignored' => $this->ignoredAttributes, | ||
'camelized' => $this->camelizedAttributes, | ||
])); | ||
} catch (\Throwable $exception) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not here, it's a very specific edge case, see #36332 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't do that, if any value in the context contains a Doctrine entity, an error can be thrown, leading to a 500. |
||
// The context cannot be serialized, skip the cache | ||
return false; | ||
} | ||
} | ||
|
||
try { | ||
return md5($format.serialize([ | ||
'context' => $context, | ||
|
Uh oh!
There was an error while loading. Please reload this page.