diff --git a/src/Actions/DuplicateEntry.php b/src/Actions/DuplicateEntry.php index 96e90e2426..efef0f471a 100644 --- a/src/Actions/DuplicateEntry.php +++ b/src/Actions/DuplicateEntry.php @@ -102,10 +102,17 @@ private function duplicateEntry(Entry $original, ?string $origin = null) }); if ($originalParent && $originalParent !== $original->id()) { - $entry->structure() - ->in($original->locale()) - ->appendTo($originalParent->id(), $entry) - ->save(); + if ($entry->structure()->expectsRoot() && $entry->structure()->in($entry->locale())->root()['entry'] === $originalParent->id()) { + $entry->structure() + ->in($original->locale()) + ->append($entry) + ->save(); + } else { + $entry->structure() + ->in($original->locale()) + ->appendTo($originalParent->id(), $entry) + ->save(); + } } return $entry; @@ -127,10 +134,6 @@ protected function getEntryParentFromStructure(Entry $entry) return null; } - if ($entry->structure()->expectsRoot() && $entry->structure()->in($entry->locale())->root()['entry'] === $parentEntry->id()) { - return null; - } - return $parentEntry; }