diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index ad2809c029c59..fe638364b9d0d 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -349,7 +349,7 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void { /** * Retrieve the path relative to the current user root folder. - * If no user is connected, try to use the node's owner. + * If no user is connected, use the node's owner. */ private function getPathForNode(Node $node): ?string { try { @@ -357,12 +357,8 @@ private function getPathForNode(Node $node): ?string { ->getUserFolder(\OC_User::getUser()) ->getRelativePath($node->getPath()); } catch (\Throwable $ex) { - $owner = $node->getOwner(); - if ($owner === null) { - return null; - } return $this->rootFolder - ->getUserFolder($owner->getUid()) + ->getUserFolder($node->getOwner()->getUid()) ->getRelativePath($node->getPath()); } }