From 729b20f6b22fdeeb569a5b4f8871842aaf46f4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 6 Jan 2016 07:50:20 +0100 Subject: [PATCH 1/2] [Serializer] Unset object_to_populate after using it --- .../Component/Serializer/Normalizer/AbstractNormalizer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 554f36c585809..421c27fcb9c65 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -279,7 +279,7 @@ protected function prepareForDenormalization($data) * Instantiates an object using constructor parameters when needed. * * This method also allows to denormalize data into an existing object if - * it is present in the context with the object_to_populate key. + * it is present in the context with the object_to_populate key then remove this key. * * @param array $data * @param string $class @@ -298,7 +298,10 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref is_object($context['object_to_populate']) && $class === get_class($context['object_to_populate']) ) { - return $context['object_to_populate']; + $object = $context['object_to_populate']; + unset($context['object_to_populate']); + + return $object; } $constructor = $reflectionClass->getConstructor(); From b59c115f114bf29997a982c80a5c9d700599eb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 11 Jan 2016 21:54:09 +0100 Subject: [PATCH 2/2] Update PHPDoc --- .../Component/Serializer/Normalizer/AbstractNormalizer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 421c27fcb9c65..b431a17401945 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -279,7 +279,9 @@ protected function prepareForDenormalization($data) * Instantiates an object using constructor parameters when needed. * * This method also allows to denormalize data into an existing object if - * it is present in the context with the object_to_populate key then remove this key. + * it is present in the context with the object_to_populate. This object + * is removed from the context before being returned to avoid side effects + * when recursively normalizing an object graph. * * @param array $data * @param string $class pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy