From 51fa2e3b1918921b42283aac34bbca210ae8180e Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 17 Jan 2024 17:07:59 +0100 Subject: [PATCH] Improve path resolution in files_version hooks Signed-off-by: Louis Chemineau --- .../lib/Listener/FileEventsListener.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index 5fe41f76e492e..206c75ec6ec39 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -350,16 +350,24 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void { private function getPathForNode(Node $node): ?string { $user = $this->userSession->getUser()?->getUID(); if ($user) { - return $this->rootFolder + $path = $this->rootFolder ->getUserFolder($user) ->getRelativePath($node->getPath()); + + if ($path !== null) { + return $path; + } } $owner = $node->getOwner()?->getUid(); if ($owner) { - return $this->rootFolder + $path = $this->rootFolder ->getUserFolder($owner) ->getRelativePath($node->getPath()); + + if ($path !== null) { + return $path; + } } return null;