Skip to content

Commit 81690f7

Browse files
author
Flaviu Chelaru
committed
hotfix/rebuild-tree
rebuild tree (lft, rgt is 0) calculates the node edges incorrectly
1 parent ac35e35 commit 81690f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Behavior.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ public function processUpdate(ModelInterface $model): void
222222

223223
$right = $parentModel->readAttribute(self::$rightKey);
224224
$depth = $parentModel->readAttribute(self::$depthKey);
225-
if (
226-
$parentModel->readAttribute(self::$rightKey) > $currentModel->readAttribute(self::$rightKey)
225+
if ($currentModel->readAttribute(self::$rightKey) == 0) {
226+
$right = $parentModel->readAttribute(self::$rightKey);
227+
$depth = $parentModel->readAttribute(self::$depthKey) + 1;
228+
} elseif ($parentModel->readAttribute(self::$rightKey) > $currentModel->readAttribute(self::$rightKey)
227229
&& $parentModel->readAttribute(self::$rightKey) > $currentModel->readAttribute(self::$leftKey)
228230
) {
229231
$right = $parentModel->readAttribute(self::$rightKey) - 2;

0 commit comments

Comments
 (0)