Skip to content
This repository
Browse code

Merge pull request #470 from uwej711/check_collection

fix issue when reordering children of uninitialized parent proxy
  • Loading branch information...
commit 07580c0a49713f611ae7e04182efbc3822dfbbab 2 parents 5d2e990 + f5e055e
Lukas Kahwe Smith authored April 14, 2014
4  lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -2505,7 +2505,9 @@ private function executeReorders($documents)
2505 2505
                     $class = $this->dm->getClassMetadata(get_class($parent));
2506 2506
                     foreach ($class->childrenMappings as $fieldName) {
2507 2507
                         $children = $class->reflFields[$fieldName]->getValue($parent);
2508  
-                        $children->setInitialized(false);
  2508
+                        if ($children instanceof PersistentCollection) {
  2509
+                            $children->setInitialized(false);
  2510
+                        }
2509 2511
                     }
2510 2512
                 }
2511 2513
             }
9  tests/Doctrine/Tests/ODM/PHPCR/Functional/ReorderTest.php
@@ -189,6 +189,15 @@ public function testReorderAfterRemove()
189 189
         $this->dm->reorder($parent, 'first', 'second', false);
190 190
     }
191 191
 
  192
+    public function testReorderParentProxy()
  193
+    {
  194
+        $first = $this->dm->find(null, '/functional/source/first');
  195
+        $parent = $first->getParent();
  196
+        $this->dm->reorder($parent, 'first', 'second', false);
  197
+        $this->dm->flush();
  198
+        $this->assertSame(array('second', 'first', 'third', 'fourth'), $this->getChildrenNames($parent->getChildren()));
  199
+    }
  200
+
192 201
     private function getChildrenNames($children)
193 202
     {
194 203
         $result = array();

0 notes on commit 07580c0

Please sign in to comment.
Something went wrong with that request. Please try again.