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 282eb9c

Browse filesBrowse files
dunglasfabpot
authored andcommitted
[Serializer] Include the format in the cache key
1 parent 414d9ef commit 282eb9c
Copy full SHA for 282eb9c

File tree

1 file changed

+6
-5
lines changed
Filter options

1 file changed

+6
-5
lines changed

‎src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function supportsNormalization($data, $format = null)
5656
public function normalize($object, $format = null, array $context = array())
5757
{
5858
if (!isset($context['cache_key'])) {
59-
$context['cache_key'] = $this->getCacheKey($context);
59+
$context['cache_key'] = $this->getCacheKey($format, $context);
6060
}
6161

6262
if ($this->isCircularReference($object, $context)) {
@@ -169,7 +169,7 @@ public function supportsDenormalization($data, $type, $format = null)
169169
public function denormalize($data, $class, $format = null, array $context = array())
170170
{
171171
if (!isset($context['cache_key'])) {
172-
$context['cache_key'] = $this->getCacheKey($context);
172+
$context['cache_key'] = $this->getCacheKey($format, $context);
173173
}
174174
$allowedAttributes = $this->getAllowedAttributes($class, $context, true);
175175
$normalizedData = $this->prepareForDenormalization($data);
@@ -336,14 +336,15 @@ private function isMaxDepthReached($class, $attribute, array &$context)
336336
/**
337337
* Gets the cache key to use.
338338
*
339-
* @param array $context
339+
* @param string|null $format
340+
* @param array $context
340341
*
341342
* @return bool|string
342343
*/
343-
private function getCacheKey(array $context)
344+
private function getCacheKey($format, array $context)
344345
{
345346
try {
346-
return md5(serialize($context));
347+
return md5($format.serialize($context));
347348
} catch (\Exception $exception) {
348349
// The context cannot be serialized, skip the cache
349350
return false;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.