fix: access shared and delegated trashbin objects#60648
Open
hamza221 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com> Assisted-by: claude:Opus 4.7 (1M context)
Contributor
Author
|
/backport to stable34 |
Contributor
Author
|
/backport to stable33 |
Contributor
Author
|
/backport to stable32 |
There was a problem hiding this comment.
Pull request overview
This PR expands the CalDAV trashbin to surface deleted calendar objects that are accessible via calendar sharing and via calendar proxy delegation, and adds permission enforcement so only sufficiently privileged sharees/proxies can restore or permanently delete entries.
Changes:
- Extend deleted-object listing/lookup in
CalDavBackendto include owned + shared calendars and proxy delegators, and to compute an effective access level per entry. - Update trashbin collection/object nodes to use the new backend lookup and to restrict restore/permanent delete for read-only access paths.
- Refactor deleted-object row building into a shared helper (
rowToDeletedCalendarObject) and add helpers for principal resolution and shared-calendar filtering.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObjectsCollection.php | Switches child lookup to a principal-aware deleted-object lookup and simplifies calendarQuery() mapping. |
| apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php | Adds access checks for restore/permanent delete and adapts ACL generation based on effective access. |
| apps/dav/lib/CalDAV/CalDavBackend.php | Adds shared/proxy-aware deleted-object listing and single-object lookup, with effective-access and principal resolution helpers. |
Comments suppressed due to low confidence (1)
apps/dav/lib/CalDAV/CalDavBackend.php:2683
- New trashbin behavior (shared calendars + proxy delegation + access overlay selection) is complex and currently untested. Since apps/dav has extensive CalDavBackend unit coverage, please add tests that cover: (1) deduping the same deleted object across multiple accessible paths while keeping the most permissive access, and (2) proxy-read vs proxy-write vs direct share permissions for restore/permanent delete.
public function getDeletedCalendarObjectByIdForPrincipal(int $id, string $principalUri): ?array {
// Visit every accessible path (self + delegators) and keep the most
// permissive row, so canModify() doesn't get a read-only view when a
// write path also exists.
$candidates = [];
$row = $this->findDeletedCalendarObjectForPrincipal($id, $principalUri, null);
if ($row !== null) {
$candidates[$id] = $row;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1204
to
+1212
| $result = $this->collectDeletedCalendarObjectsForPrincipal($principalUri, null); | ||
| foreach ($this->getProxyDelegators($principalUri) as $delegator => $hasProxyWrite) { | ||
| $overlay = $hasProxyWrite ? Backend::ACCESS_READ_WRITE : Backend::ACCESS_READ; | ||
| $result = array_merge($result, $this->collectDeletedCalendarObjectsForPrincipal($delegator, $overlay)); | ||
| } | ||
| return $result; | ||
| } | ||
|
|
||
| /** |
Comment on lines
+1213
to
+1220
| * Run the owned + shared trashbin queries for $principalUri and merge into $result. | ||
| * | ||
| * @param string $principalUri principal whose calendars to scan. | ||
| * @param array $result accumulator keyed by calendar object id; merged in-place. | ||
| * @param int|null $proxyOverlay if non-null, the entries are being collected on | ||
| * behalf of a different accessor via calendar-proxy; the value caps the | ||
| * effective share access for that accessor (READ_WRITE for proxy-write, | ||
| * READ for proxy-read). null means $principalUri is the accessor itself. |
| ->from('calendarobjects', 'co') | ||
| ->join('co', 'calendars', 'c', $query->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT)) | ||
| ->where($query->expr()->eq('co.id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) | ||
| ->andWhere($query->expr()->eq('c.principaluri', $query->createNamedParameter($principalUri))) |
| ->from('calendarobjects', 'co') | ||
| ->join('co', 'calendars', 'c', $select->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT)) | ||
| ->andWhere($select->expr()->eq('co.id', $select->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) | ||
| ->andWhere($select->expr()->isNotNull('co.deleted_at')) |
GVodyanov
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted-by: claude:Opus 4.7 (1M context)
Summary
Checklist
3. to review, feature component)stable32)AI (if applicable)