diff --git a/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php b/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php index c930605e63..4339229ed7 100644 --- a/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php @@ -453,6 +453,15 @@ public function hydrate($document, $data, array $hints = array()) $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $hints); if ($document instanceof Proxy) { $document->__isInitialized__ = true; + $document->__setInitializer(null); + $document->__setCloner(null); + // lazy properties may be left uninitialized + $properties = $document->__getLazyProperties(); + foreach ($properties as $propertyName => $property) { + if ( ! isset($document->$propertyName)) { + $document->$propertyName = $properties[$propertyName]; + } + } } // Invoke the postLoad lifecycle callbacks and listeners diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php index 99037b9f5a..2ddcf51050 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1346Test.php @@ -12,22 +12,21 @@ class GH1346Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest */ public function testPublicProperty() { - - $refrenced1 = new GH1346ReferencedDocument(); - $refrenced2 = new GH1346ReferencedDocument(); + $referenced1 = new GH1346ReferencedDocument(); + $referenced2 = new GH1346ReferencedDocument(); $gH1346Document = new GH1346Document(); - $gH1346Document->addReference($refrenced1); + $gH1346Document->addReference($referenced1); - $this->dm->persist($refrenced2); - $this->dm->persist($refrenced1); + $this->dm->persist($referenced2); + $this->dm->persist($referenced1); $this->dm->persist($gH1346Document); $this->dm->flush(); $this->dm->clear(); $gH1346Document = $this->dm->getRepository(__NAMESPACE__ . '\GH1346Document')->find($gH1346Document->getId()); - $refrenced2 = $this->dm->getRepository(__NAMESPACE__ . '\GH1346ReferencedDocument')->find($refrenced2->getId()); + $referenced2 = $this->dm->getRepository(__NAMESPACE__ . '\GH1346ReferencedDocument')->find($referenced2->getId()); - $gH1346Document->addReference($refrenced2); + $gH1346Document->addReference($referenced2); $this->dm->persist($gH1346Document); $this->dm->flush(); @@ -76,7 +75,7 @@ public function getReferences() */ class GH1346ReferencedDocument { - /** @ODM\String() */ + /** @ODM\Field(type="string") */ public $test; /** @ODM\Id */