@@ -56,7 +56,7 @@ public function supportsNormalization($data, $format = null)
56
56
public function normalize ($ object , $ format = null , array $ context = array ())
57
57
{
58
58
if (!isset ($ context ['cache_key ' ])) {
59
- $ context ['cache_key ' ] = $ this ->getCacheKey ($ context );
59
+ $ context ['cache_key ' ] = $ this ->getCacheKey ($ format , $ context );
60
60
}
61
61
62
62
if ($ this ->isCircularReference ($ object , $ context )) {
@@ -169,7 +169,7 @@ public function supportsDenormalization($data, $type, $format = null)
169
169
public function denormalize ($ data , $ class , $ format = null , array $ context = array ())
170
170
{
171
171
if (!isset ($ context ['cache_key ' ])) {
172
- $ context ['cache_key ' ] = $ this ->getCacheKey ($ context );
172
+ $ context ['cache_key ' ] = $ this ->getCacheKey ($ format , $ context );
173
173
}
174
174
$ allowedAttributes = $ this ->getAllowedAttributes ($ class , $ context , true );
175
175
$ normalizedData = $ this ->prepareForDenormalization ($ data );
@@ -336,14 +336,15 @@ private function isMaxDepthReached($class, $attribute, array &$context)
336
336
/**
337
337
* Gets the cache key to use.
338
338
*
339
- * @param array $context
339
+ * @param string|null $format
340
+ * @param array $context
340
341
*
341
342
* @return bool|string
342
343
*/
343
- private function getCacheKey (array $ context )
344
+ private function getCacheKey ($ format , array $ context )
344
345
{
345
346
try {
346
- return md5 (serialize ($ context ));
347
+ return md5 ($ format . serialize ($ context ));
347
348
} catch (\Exception $ exception ) {
348
349
// The context cannot be serialized, skip the cache
349
350
return false ;
0 commit comments