Skip to content

Commit 8dc4d3a

Browse files
committed
Fix for move below with no existing siblings
1 parent 602f0cd commit 8dc4d3a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Storage/DbalNestedSet.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,13 @@ protected function moveSubTreeToPosition($newLeftPosition, Node $node) {
349349

350350
// Calculate depth difference.
351351
$newNode = $this->getNodeAtPosition($newLeftPosition);
352-
$depthDiff = $newNode->getDepth() - $node->getDepth();
352+
if (!$newNode) {
353+
// No other children at this position, new depth = 1.
354+
$depthDiff = 1 - $node->getDepth();
355+
}
356+
else {
357+
$depthDiff = $newNode->getDepth() - $node->getDepth();
358+
}
353359

354360
// Backwards movement must account for new space.
355361
if ($distance < 0) {

0 commit comments

Comments
 (0)