From 2a81adc1fc79eae8f9a3b7cac61bec90ceaddbb0 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 3 Apr 2015 15:28:53 +0100 Subject: [PATCH] Correcting `ObjectHydrator` logic: if an `array` is a default value for a collection-valued property, it should be cast to a `Collection` --- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index c1bcc2591..3cedaada0 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -189,8 +189,8 @@ class ObjectHydrator extends AbstractHydrator $relation = $class->associationMappings[$fieldName]; $value = $class->reflFields[$fieldName]->getValue($entity); - if ($value === null) { - $value = new ArrayCollection; + if ($value === null || is_array($value)) { + $value = new ArrayCollection((array) $value); } if ( ! $value instanceof PersistentCollection) {