From 654436698cf41507275a9dd27d2d95231ca848a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 11 Feb 2025 16:21:26 +0100 Subject: [PATCH] fix(trash): Fix deleting items from public share with write access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When no user in session, use an empty string as deleted_by, which shows as "Unknown" in the UI. Signed-off-by: Côme Chilliet --- lib/Trash/TrashBackend.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index e878dec6c..1d5090367 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -239,9 +239,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool { $fileEntry = $storage->getCache()->get($internalPath); $folderId = $storage->getFolderId(); $user = $this->userSession->getUser(); - if (!$user) { - throw new \Exception('file moved to trash with no user in context'); - } + // ensure the folder exists $this->getTrashFolder($folderId); @@ -263,7 +261,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool { $originalLocation = $storage->getWrapperStorage()->getUnjailedPath($originalLocation); } - $this->trashManager->addTrashItem($folderId, $name, $time, $originalLocation, $fileEntry->getId(), $user->getUID()); + $this->trashManager->addTrashItem($folderId, $name, $time, $originalLocation, $fileEntry->getId(), $user?->getUID() ?? ''); // some storage backends (object/encryption) can either already move the cache item or cause the target to be scanned // so we only conditionally do the cache move here