Skip to content

fix(trash): allow restoring trashed items in "no permission" folders#4880

Open
solracsf wants to merge 1 commit into
masterfrom
fix/allow-restoring-trashed-items
Open

fix(trash): allow restoring trashed items in "no permission" folders#4880
solracsf wants to merge 1 commit into
masterfrom
fix/allow-restoring-trashed-items

Conversation

@solracsf

@solracsf solracsf commented Jul 10, 2026

Copy link
Copy Markdown
Member

Fixes #4830

With acl_default_no_permission set, trash items could not be restored or permanently deleted, and were hidden from regular users. Two causes:

  1. TrashBackend::userHasAccessToItem() applied the deny-by-default base even when ACL is disabled (the creation dialog sets the flag without enabling ACL). It now skips the per-path check when ACL is off, and createFolder() enables ACL when the flag is set.
  2. The check ANDed two evaluations, each seeded with the folder base; with the base at 0 the trash side could never rise above 0. It is now a single evaluation: original-location permissions (base + parent rules), with the item's own rules, which move with the item into the trash storage, applied on top.

Behavior deltas, both matching the live mounts: leftover rules are ignored for trash while ACL is disabled; an allow rule on the item itself now overrides a parent deny (previously denied by the AND), which also makes item-only grants restorable.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@solracsf solracsf added this to the Nextcloud 34 milestone Jul 10, 2026
@solracsf solracsf added bug 3. to review Items that need to be reviewed feature: acl Items related to the groupfolders ACL or "Advanced Permissions" feature: trashbin Items related to the trashbin feature labels Jul 10, 2026
@solracsf

Copy link
Copy Markdown
Member Author

/backport to stable34

@solracsf

Copy link
Copy Markdown
Member Author

/backport to stable33

Comment thread lib/Folder/FolderManager.php Outdated
Comment on lines -336 to 347
$activePermissions = $aclManager->getACLPermissionsForPath($item->folder->id, $item->getGroupTrashFolderStorageId(), $trashPath);
$activePermissions = $aclManager->getACLPermissionsForPath($item->folder->id, $item->getGroupTrashFolderStorageId(), $trashPath, baseOverride: Constants::PERMISSION_ALL);
$originalPath = $item->folder->rootCacheEntry->getPath() . '/' . $item->getInternalOriginalLocation() . $pathInsideItem;
$originalLocationPermissions = $aclManager->getACLPermissionsForPath($item->folder->id, $item->getGroupFolderStorageId(), $originalPath);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we check trash ACLs in the first place, if we check the ACLs for the original location anyway? The argument from your PR description doesn't make a lot of sense to me, because must either check all ACLs the same way or only check the ones of the original location.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will check this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rules are keyed by file id and move with the item into the trash storage, so the trash path is the only place the item's own rules can still be found, the original location only yields the parent rules. They're now checked the same way: one evaluation, original-location permissions as base, trash-path rules on top.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsf force-pushed the fix/allow-restoring-trashed-items branch from 9012fbe to 46b4957 Compare July 15, 2026 15:47
@solracsf
solracsf requested a review from provokateurin July 15, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Items that need to be reviewed backport-request bug feature: acl Items related to the groupfolders ACL or "Advanced Permissions" feature: trashbin Items related to the trashbin feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot restore files when enabling flag acl_default_no_permission

2 participants