Skip to content

Commit

Permalink
Don't merge value objects
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ddeboer committed Oct 3, 2014
1 parent 7bea65f commit 5f8b526
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Alice/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5f8b526

Please sign in to comment.