Skip to content

Commit 574c909

Browse files
committed
fix(trash): Fix deleting items from public share with write access
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 <[email protected]>
1 parent df8560f commit 574c909

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/Trash/TrashBackend.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool {
237237
$fileEntry = $storage->getCache()->get($internalPath);
238238
$folderId = $storage->getFolderId();
239239
$user = $this->userSession->getUser();
240-
if (!$user) {
241-
throw new \Exception('file moved to trash with no user in context');
242-
}
240+
243241
// ensure the folder exists
244242
$this->getTrashFolder($folderId);
245243

@@ -261,7 +259,7 @@ public function moveToTrash(IStorage $storage, string $internalPath): bool {
261259
$originalLocation = $storage->getWrapperStorage()->getUnjailedPath($originalLocation);
262260
}
263261

264-
$this->trashManager->addTrashItem($folderId, $name, $time, $originalLocation, $fileEntry->getId(), $user->getUID());
262+
$this->trashManager->addTrashItem($folderId, $name, $time, $originalLocation, $fileEntry->getId(), $user?->getUID() ?? '');
265263

266264
// some storage backends (object/encryption) can either already move the cache item or cause the target to be scanned
267265
// so we only conditionally do the cache move here

0 commit comments

Comments
 (0)