Skip to content

Add model rollback and transaction callbacks - #852

Open
hrach wants to merge 2 commits into
mainfrom
fix/orm-rollback-transactions
Open

hrach wants to merge 2 commits into
mainfrom
fix/orm-rollback-transactions

Conversation

@hrach

@hrach hrach commented Nov 14, 2026

Copy link
Copy Markdown
Member

Persistence and commit failures can leave an open transaction, stale entity state, and pending flush notifications. Add model-level rollback and a transaction callback that coordinates storage cleanup with repository reset.

  • Add Model::rollback() for rollback-capable mappers, including best-effort cleanup across repositories and preserved cleanup errors.
  • Add Model::transactional() to run a callback once, flush, and commit on one shared transaction coordinator. Callback, persistence, flush, and commit failures reset repository state; flushes inside the callback do not commit the scope.
  • Retain affected entities in repository operation queues until completion; add no identity-map tracking. Reject nested model scopes, existing connection transactions, and incompatible mapper configurations.
  • Update the DBAL requirement to dev-main and document the APIs and custom implementation changes. Existing flush events still run before the final commit; automatic retries are outside this change.

Validation: full PostgreSQL and in-memory suite passes (623 tests, 42 skipped), PHPStan passes, and DressCode passes.

Refs #801.

@hrach

hrach commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

This change is part of the following stack:

Change managed by git-spice.

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.

A transaction is created and never terminated if flush throws an error.

1 participant