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 ?
Activity
Jonathan H. Wage
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Closed [ 6 ] |
| Fix Version/s | 1.0.0BETA2 [ 10092 ] | |
| Resolution | Cannot Reproduce [ 5 ] |
JF Bustarret
made changes -
| Resolution | Cannot Reproduce [ 5 ] | |
| Status | Closed [ 6 ] | Reopened [ 4 ] |
JF Bustarret
made changes -
| Affects Version/s | 1.0.0BETA3 [ 10124 ] | |
| Affects Version/s | 1.0.0BETA2 [ 10092 ] | |
| Description |
Here is my class hierarchy (classes & attributes renamed for a better understanding) : {noformat} /** @Document @InheritanceType("COLLECTION_PER_CLASS") **/ class Parent { /** @ReferenceOne(targetDocument="Child") **/ protected $child; } /** @Document **/ class Child extends Parent { } {noformat} When doing : {noformat} $parent->setXXX($value); $parent->getChild()->setXXX($value2) {noformat} the $parent->getChild() document is saved to the Parent collection. It looks like the problems lies in UnitOfWork::executeUpdates : {noformat} if (get_class($document) == $className || $document instanceof Proxy && $document instanceof $className) { {noformat} $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 ? |
Here is my class hierarchy (classes & attributes renamed for a better understanding) : {noformat} /** @Document @InheritanceType("COLLECTION_PER_CLASS") **/ class Parent { /** @ReferenceOne(targetDocument="Child") **/ protected $child; } /** @Document **/ class Child extends Parent { } {noformat} When doing : {noformat} $parent->setXXX($value); $parent->getChild()->setXXX($value2) {noformat} the $parent->getChild() document is saved to the Parent collection. It looks like the problems lies in UnitOfWork::executeUpdates : {noformat} if (get_class($document) == $className || $document instanceof Proxy && $document instanceof $className) { {noformat} $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 ? |