Browse Source

[tree] fix for inserted in memory node synchronization

Gediminas Morkevicius 14 năm trước cách đây
mục cha
commit
0a2b444a63
2 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 4 0
      lib/Gedmo/Tree/Strategy/ORM/Nested.php
  2. 1 0
      tests/phpunit.dist.xml

+ 4 - 0
lib/Gedmo/Tree/Strategy/ORM/Nested.php

@@ -277,11 +277,15 @@ class Nested implements Strategy
 
         $meta->getReflectionProperty($config['left'])->setValue($node, $parentRight);
         $meta->getReflectionProperty($config['right'])->setValue($node, $parentRight + 1);
+        $oid = spl_object_hash($node);
+        $em->getUnitOfWork()->setOriginalEntityProperty($oid, $config['left'], $parentRight);
+        $em->getUnitOfWork()->setOriginalEntityProperty($oid, $config['right'], $parentRight + 1);
         $dql = "UPDATE {$meta->rootEntityName} node";
         $dql .= " SET node.{$config['left']} = " . ($parentRight) . ', ';
         $dql .= " node.{$config['right']} = " . ($parentRight + 1);
         if (isset($level)) {
             $dql .= ", node.{$config['level']} = " . $level;
+            $em->getUnitOfWork()->setOriginalEntityProperty($oid, $config['level'], $level);
         }
         $dql .= " WHERE node.{$identifierField} = {$nodeId}";
         $em->createQuery($dql)->getSingleScalarResult();

+ 1 - 0
tests/phpunit.dist.xml

@@ -16,6 +16,7 @@
             <file>./Gedmo/Tree/RepositoryTest.php</file>
             <file>./Gedmo/Tree/TranslatableSluggableTreeTest.php</file>
             <file>./Gedmo/Tree/TreeTest.php</file>
+            <file>./Gedmo/Tree/InMemoryUpdatesTest.php</file>
         </testsuite>
         <testsuite name="Timestampable Extension">
             <directory suffix=".php">./Gedmo/Timestampable/</directory>