Details
-
Type:
Bug
-
Status:
Reopened
-
Priority:
Critical
-
Resolution: Unresolved
-
Affects Version/s: 1.0.0BETA3
-
Fix Version/s: None
-
Component/s: Document Manager
-
Labels:None
Description
Here is my class hierarchy (classes & attributes renamed for a better understanding) :
/** @Document @InheritanceType("COLLECTION_PER_CLASS") **/
class Parent {
/** @ReferenceOne(targetDocument="Child") **/
protected $child;
}
/** @Document **/
class Child extends Parent {
}
When doing :
$parent->setXXX($value); $parent->getChild()->setXXX($value2)
the $parent->getChild() document is saved to the Parent collection.
It looks like the problems lies in UnitOfWork::executeUpdates :
if (get_class($document) == $className || $document instanceof Proxy && $document instanceof $className) {
$child_document is an instance of Proxy (ChildProxy) and also an instance of Parent => saved using the Parent persister.
Shouldn't the test be : get_class($document) == $className || get_class($document) == $className_of_Proxy ?
As a side note : why "if ($class->isEmbeddedDocument)
{ continue; }" is within the foreach and not a "if ($class->isEmbeddedDocument)
{ return; }" at the beginning of the method ?
I added a test for this here and it appears to be passing: https://github.com/doctrine/mongodb-odm/commit/3f24d77cc04adc0bb5532333e33826100457c666