@@ -66,6 +66,7 @@ public function addNodeAfter(Node $target, NodeKey $nodeKey) {
6666 protected function insertNodeAtPostion ($ newLeftPosition , $ depth , NodeKey $ nodeKey ) {
6767
6868 try {
69+ $ this ->connection ->setAutoCommit (FALSE );
6970 $ this ->connection ->beginTransaction ();
7071
7172 // Make space for inserting node.
@@ -85,6 +86,9 @@ protected function insertNodeAtPostion($newLeftPosition, $depth, NodeKey $nodeKe
8586 $ this ->connection ->rollBack ();
8687 throw $ e ;
8788 }
89+ finally {
90+ $ this ->connection ->setAutoCommit (TRUE );
91+ }
8892 return $ newNode ;
8993
9094 }
@@ -271,6 +275,7 @@ public function deleteSubTree(Node $node) {
271275 $ width = $ right - $ left + 1 ;
272276
273277 try {
278+ $ this ->connection ->setAutoCommit (FALSE );
274279 $ this ->connection ->beginTransaction ();
275280
276281 // Delete the node.
@@ -292,6 +297,9 @@ public function deleteSubTree(Node $node) {
292297 $ this ->connection ->rollBack ();
293298 throw $ e ;
294299 }
300+ finally {
301+ $ this ->connection ->setAutoCommit (TRUE );
302+ }
295303
296304 }
297305
@@ -347,6 +355,7 @@ protected function moveSubTreeToPosition($newLeftPosition, Node $node, $newDepth
347355 $ distance = $ newLeftPosition - $ node ->getLeft ();
348356 $ tempPos = $ node ->getLeft ();
349357
358+ $ this ->connection ->setAutoCommit (FALSE );
350359 $ this ->connection ->beginTransaction ();
351360
352361 // Calculate depth difference.
@@ -386,6 +395,9 @@ protected function moveSubTreeToPosition($newLeftPosition, Node $node, $newDepth
386395 $ this ->connection ->rollBack ();
387396 throw $ e ;
388397 }
398+ finally {
399+ $ this ->connection ->setAutoCommit (TRUE );
400+ }
389401
390402 }
391403
0 commit comments