From 5f8b526b31766399b02308543e70f709edb2d23c Mon Sep 17 00:00:00 2001 From: David de Boer Date: Fri, 3 Oct 2014 13:33:30 +0200 Subject: [PATCH] Don't merge value objects The bundle currently tries to call $om->merge() on value objects, defined with (local), too. This causes: Notice: Undefined offset: 0 in vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 729 This PR checks whether an object has identity before trying to merge it. --- Alice/Loader.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Alice/Loader.php b/Alice/Loader.php index b2efd851..2f01bfb3 100644 --- a/Alice/Loader.php +++ b/Alice/Loader.php @@ -71,7 +71,13 @@ public function setObjectManager(ObjectManager $manager) $newReferences = array(); foreach ($this->references as $name => $reference) { - $newReferences[$name] = $this->persister->merge($reference); + // Don't merge value objects, e.g. Doctrine embeddables + $metadata = $manager->getClassMetadata(get_class($reference)); + if (count($metadata->getIdentifier()) > 0) { + $reference = $this->persister->merge($reference); + } + + $newReferences[$name] = $reference; } $this->references = new ArrayCollection($newReferences);