Skip to content

chore(trashbin): deprecate abortOperation on BeforeNodeRestoredEvent / switch to AbortedEventException#59043

Open
joshtrichards wants to merge 6 commits intomasterfrom
jtr/chore-trashbin-drop-abortOperation-usage
Open

chore(trashbin): deprecate abortOperation on BeforeNodeRestoredEvent / switch to AbortedEventException#59043
joshtrichards wants to merge 6 commits intomasterfrom
jtr/chore-trashbin-drop-abortOperation-usage

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Mar 18, 2026

  • Resolves: #

Summary

Deprecates BeforeNodeRestoredEvent::abortOperation() to match the deprecation already applied to BeforeNodeDeletedEvent::abortOperation() and BeforeNodeRenamedEvent::abortOperation() in Nextcloud 29. BeforeNodeRestoredEvent was missed in that round.

Changes:

  • Switched all three $event->abortOperation() call sites in files_trashbin's SyncLivePhotosListener::handleRestore() to throw AbortedEventException directly.
  • Adjusted BeforeNodeRestoredEvent::abortOperation() to throw AbortedEventException internally (matching the files app's BeforeNodeDeletedEvent::abortOperation()), and marked it @deprecated.
  • Added try/catch for AbortedEventException at the Trashbin::restore() dispatch site, consistent with how HookConnector::delete() handles it for the files app.

Fixes a bug: In the existing implementation, Trashbin::restore()'s if (!$run) check is dead code -- abortOperation() sets $run = false but immediately throws, so the exception unwinds past the check. The operation is aborted only because an uncaught exception propagates up the stack as an HTTP 500, not via the intended graceful return false path. This PR makes the abort mechanism work as designed + match its counterparts in the files app.

TODO

  • ...

Checklist

AI (if applicable)

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

…ntException

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added this to the Nextcloud 34 milestone Mar 18, 2026
@joshtrichards
Copy link
Member Author

/backport to stable34

@joshtrichards joshtrichards added feature: trashbin bug ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) 3. to review Waiting for reviews labels Mar 18, 2026
@joshtrichards joshtrichards marked this pull request as ready for review March 18, 2026 14:21
@joshtrichards joshtrichards requested a review from a team as a code owner March 18, 2026 14:21
@joshtrichards joshtrichards requested review from CarlSchwan, artonge, icewind1991, leftybournes and salmart-dev and removed request for a team March 18, 2026 14:21
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews backport-request bug feature: trashbin ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants