Details
Description
Occurs in trunk revision 7203
We have two entity with an empty oneToMany association
Client -> Email
When there is no email, I don't know why, the collection is filled with EmailProxy. (Data come from a query hydrated object)
in UnitOfWork::_computeAssociationChanges I see there is a test for Proxy entity but it does not apply to collection.
private function _computeAssociationChanges($assoc, $value) { ..... // Look through the entities, and in any of their associations, for transient // enities, recursively. ("Persistence by reachability") if ($assoc->isOneToOne()) { if ($value instanceof Proxy && ! $value->__isInitialized__) { return; // Ignore uninitialized proxy objects } $value = array($value); } else if ($value instanceof PersistentCollection) { $value = $value->unwrap(); } $targetClass = $this->_em->getClassMetadata($assoc->targetEntityName); foreach ($value as $entry) { ...... } }
Maybe you could try to check for Proxy in second loop to catch both cases :
private function _computeAssociationChanges($assoc, $value) { ..... // Look through the entities, and in any of their associations, for transient // enities, recursively. ("Persistence by reachability") if ($assoc->isOneToOne()) { $value = array($value); } else if ($value instanceof PersistentCollection) { $value = $value->unwrap(); } $targetClass = $this->_em->getClassMetadata($assoc->targetEntityName); foreach ($value as $entry) { if ($entry instanceof Proxy && ! $entry->__isInitialized__) { continue; // Ignore uninitialized proxy objects } ..... } }
At your request I could do a UnitTest Case