[Serializer] Include the format in the cache key#19352
Closed
dunglas wants to merge 3 commits intosymfony:3.1from
Closed
[Serializer] Include the format in the cache key#19352dunglas wants to merge 3 commits intosymfony:3.1from
dunglas wants to merge 3 commits intosymfony:3.1from
Conversation
| { | ||
| try { | ||
| return md5(serialize($context)); | ||
| return $format.'-'.md5(serialize($context)); |
Member
There was a problem hiding this comment.
Shouldn't this be inside the md5?
Member
Author
There was a problem hiding this comment.
It's already a string and it makes the key more explicit. On the other hand if the format name is very long, it can hit the max key size. What do you think?
Member
There was a problem hiding this comment.
I'd prefer inside the md5: not format change for keys, shorters keys.
| { | ||
| try { | ||
| return md5(serialize($context)); | ||
| return md5(serialize($format.$context)); |
Member
There was a problem hiding this comment.
That does not work as $context is an array, so you would always have Array and a PHP notice for the array to string conversion.
Member
Author
There was a problem hiding this comment.
My bad, my intent was to but it before the serialize call ^^.
Member
|
Thank you @dunglas. |
fabpot
added a commit
that referenced
this pull request
Jul 13, 2016
This PR was squashed before being merged into the 3.1 branch (closes #19352). Discussion ---------- [Serializer] Include the format in the cache key | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Attributes to normalize can vary by format. For instance in API Platform normalized attributes aren't the same in JSON-LD (all attributes) and HAL (relations are not serialized in the document body). This PR fixes that. Commits ------- 282eb9c [Serializer] Include the format in the cache key
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Attributes to normalize can vary by format. For instance in API Platform normalized attributes aren't the same in JSON-LD (all attributes) and HAL (relations are not serialized in the document body).
This PR fixes that.