diff --git a/lib/Hooks/FileListener.php b/lib/Hooks/FileListener.php index abc7947d..5b478a30 100644 --- a/lib/Hooks/FileListener.php +++ b/lib/Hooks/FileListener.php @@ -356,9 +356,11 @@ public function postInsert(Node $node, bool $recurse = true): void { public function postRename(Node $source, Node $target): void { $targetUserIds = $this->getUsersWithFileAccess($target); - $usersToAdd = array_diff($targetUserIds, $this->sourceUserIds); + $usersToAdd = array_values(array_diff($targetUserIds, $this->sourceUserIds)); $existingUsers = array_diff($targetUserIds, $usersToAdd); - $ownerId = $source->getOwner() ? $source->getOwner()->getUID() : ($target->getOwner() ? $target->getOwner()->getUID() : $existingUsers[0]); + $sourceOwner = $source->getOwner(); + $targetOwner = $target->getOwner(); + $ownerId = $sourceOwner !== null ? $sourceOwner->getUID() : ($targetOwner ? $targetOwner->getUID() : $existingUsers[0]); $this->copyFaceDetectionsForNode($ownerId, $usersToAdd, $targetUserIds, $target); }