From 896739cc641bb09275e8473eb794f5a1473e03e1 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:33:09 +0100 Subject: [PATCH] Move from OC_User to UserSession Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- .../files_versions/lib/Listener/FileEventsListener.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index 5fe41f76e492e..c8b252f981857 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -323,19 +323,23 @@ public function copy_hook(Node $source, Node $target): void { * */ public function pre_renameOrCopy_hook(Node $source, Node $target): void { + $user = $this->userSession->getUser()?->getUID(); + if (!user) { + return; + } // if we rename a movable mount point, then the versions don't have // to be renamed $oldPath = $this->getPathForNode($source); $newPath = $this->getPathForNode($target); - $absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files' . $oldPath); + $absOldPath = Filesystem::normalizePath('/' . $user . '/files' . $oldPath); $manager = Filesystem::getMountManager(); $mount = $manager->find($absOldPath); $internalPath = $mount->getInternalPath($absOldPath); - if ($internalPath === '' and $mount instanceof MoveableMount) { + if ($internalPath === '' && $mount instanceof MoveableMount) { return; } - $view = new View(\OC_User::getUser() . '/files'); + $view = new View($user . '/files'); if ($view->file_exists($newPath)) { Storage::store($newPath); } else {