Skip to content

Commit

Permalink
fix(trash): Fix deleting items from public share with write access
Browse files Browse the repository at this point in the history
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 <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc authored and backportbot[bot] committed Feb 17, 2025
1 parent 38a5896 commit 6544366
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand Down

0 comments on commit 6544366

Please sign in to comment.