File tree Expand file tree Collapse file tree
lib/Doctrine/ODM/MongoDB/Persisters
tests/Doctrine/ODM/MongoDB/Tests/Functional Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -713,9 +713,11 @@ private function loadReferenceManyCollectionOwningSide(PersistentCollection $col
713713 $ documents = $ cursor ->toArray (false );
714714 foreach ($ documents as $ documentData ) {
715715 $ document = $ this ->uow ->getById ($ documentData ['_id ' ], $ class );
716- $ data = $ this ->hydratorFactory ->hydrate ($ document , $ documentData );
717- $ this ->uow ->setOriginalDocumentData ($ document , $ data );
718- $ document ->__isInitialized__ = true ;
716+ if ($ document instanceof Proxy && ! $ document ->__isInitialized ()) {
717+ $ data = $ this ->hydratorFactory ->hydrate ($ document , $ documentData );
718+ $ this ->uow ->setOriginalDocumentData ($ document , $ data );
719+ $ document ->__isInitialized__ = true ;
720+ }
719721 if ($ sorted ) {
720722 $ collection ->add ($ document );
721723 }
Original file line number Diff line number Diff line change @@ -334,9 +334,11 @@ public function testSortReferenceManyOwningSide()
334334 $ this ->assertEquals ('Group 1 ' , $ groups [0 ]->getName ());
335335 $ this ->assertEquals ('Group 2 ' , $ groups [1 ]->getName ());
336336
337+ $ groups [1 ]->setName ('Group 2a ' );
338+
337339 $ groups = $ user ->getSortedDescGroups ();
338340 $ this ->assertEquals (2 , $ groups ->count ());
339- $ this ->assertEquals ('Group 2 ' , $ groups [0 ]->getName ());
341+ $ this ->assertEquals ('Group 2a ' , $ groups [0 ]->getName ());
340342 $ this ->assertEquals ('Group 1 ' , $ groups [1 ]->getName ());
341343 }
342344
You can’t perform that action at this time.
0 commit comments