From 7352b97b1457a9460911c1d333692078d47f9a5a Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Sat, 3 Sep 2016 22:25:11 +0300 Subject: [PATCH] Fix hydration in a joined inheritance with simple array or json array SimpleArrayType and JsonArrayType convert NULL value to an empty array, which fails the null check that is used to prevent overwrite Fixes issue #5989 --- lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php index 1c21369e3..5eb8cc117 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php @@ -122,6 +122,9 @@ class SimpleObjectHydrator extends AbstractHydrator continue; } + // Check if value is null before conversion (because some types convert null to something else) + $valueIsNull = $value === null; + // Convert field to a valid PHP value if (isset($cacheKeyInfo['type'])) { $type = $cacheKeyInfo['type']; @@ -131,7 +134,7 @@ class SimpleObjectHydrator extends AbstractHydrator $fieldName = $cacheKeyInfo['fieldName']; // Prevent overwrite in case of inherit classes using same property name (See AbstractHydrator) - if ( ! isset($data[$fieldName]) || $value !== null) { + if ( ! isset($data[$fieldName]) || ! $valueIsNull) { $data[$fieldName] = $value; } }