Skip to content

Reset the force-deleting flag when a force delete throws - #242

Merged
LukeTowers merged 1 commit into
wintercms:developfrom
austinderrick:fix/halcyon-force-delete-flag
Aug 15, 2026
Merged

Reset the force-deleting flag when a force delete throws#242
LukeTowers merged 1 commit into
wintercms:developfrom
austinderrick:fix/halcyon-force-delete-flag

Conversation

@austinderrick

@austinderrick austinderrick commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

If delete() throws inside forceDelete(), the flag never resets and the datasource is stuck in force-delete mode. Every ordinary delete after that runs as a hard delete.

The fix wraps the call in try/finally so the flag always resets and the exception still reaches the caller. Two tests cover the throwing path and the happy path.

Summary by CodeRabbit

  • Bug Fixes

    • Improved force deletion cleanup so its internal state is reset even when deletion fails.
    • Deletion errors continue to be reported correctly, while successful deletions retain their existing results.
  • Tests

    • Added coverage for successful and failed force-deletion scenarios.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c30614b4-39b4-43aa-9ee8-afabeb006f82

📥 Commits

Reviewing files that changed from the base of the PR and between ad2b570 and 7aca6c4.

📒 Files selected for processing (2)
  • src/Halcyon/Datasource/Datasource.php
  • tests/Halcyon/DatasourceForceDeleteTest.php

Walkthrough

forceDelete() now clears the internal force-deleting flag in a finally block. The method still returns the deletion result and propagates exceptions. New tests cover successful deletion and deletion failure, including flag state during and after deletion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7aca6

The change ensures the force-delete flag is reset even when deletion throws, while preserving the exception for callers. No actionable merge-blocking risk remains beyond normal test checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resetting the force-deleting flag when force deletion throws.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/halcyon-force-delete-flag
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@austinderrick
austinderrick force-pushed the fix/halcyon-force-delete-flag branch from f095bdb to a31e46b Compare August 14, 2026 19:44
@LukeTowers

Copy link
Copy Markdown
Member

@austinderrick if you retarget develop I'll merge this in before I release 1.2.14 later this evening or this weekend.

If delete() throws, forceDelete() left the datasource stuck in force-deleting
mode, so every later ordinary delete on that instance ran as a hard delete.
The flag now resets in a finally block and the exception propagates.
@austinderrick
austinderrick force-pushed the fix/halcyon-force-delete-flag branch from a31e46b to 7aca6c4 Compare August 14, 2026 22:35
@austinderrick
austinderrick changed the base branch from wip/1.3 to develop August 14, 2026 22:35
@austinderrick

Copy link
Copy Markdown
Contributor Author

@LukeTowers : Updated!

@LukeTowers
LukeTowers merged commit 9c2eb4c into wintercms:develop Aug 15, 2026
13 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants