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 ea4f387

Browse filesBrowse files
committed
only call serialize once for better performance
1 parent 7b64d88 commit ea4f387
Copy full SHA for ea4f387

File tree

1 file changed

+9
-3
lines changed
Filter options

1 file changed

+9
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ private function isMaxDepthReached(array $attributesMetadata, $class, $attribute
371371
}
372372

373373
/**
374-
* Overwrite to update the cache key for the child.
374+
* Overwritten to update the cache key for the child.
375+
*
376+
* We must not mix up the attribute cache between parent and children.
375377
*
376378
* {@inheritdoc}
377379
*/
@@ -385,7 +387,7 @@ protected function createChildContext(array $parentContext, $attribute)
385387
}
386388

387389
/**
388-
* Build the cache key for the attributes cache.
390+
* Builds the cache key for the attributes cache.
389391
*
390392
* The key must be different for every option in the context that could change which attributes should be handled.
391393
*
@@ -397,7 +399,11 @@ protected function createChildContext(array $parentContext, $attribute)
397399
private function getAttributeCacheKey($format, array $context)
398400
{
399401
try {
400-
return md5($format.serialize($context).serialize($this->ignoredAttributes)).serialize($this->camelizedAttributes);
402+
return md5($format.serialize([
403+
'context' => $context,
404+
'ignored' => $this->ignoredAttributes,
405+
'camelized' => $this->camelizedAttributes,
406+
]));
401407
} catch (\Exception $exception) {
402408
// The context cannot be serialized, skip the cache
403409
return false;

0 commit comments

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