docs: add transaction side-effect recipes#10153
Open
memleakd wants to merge 1 commit intocodeigniter4:4.8from
Open
docs: add transaction side-effect recipes#10153memleakd wants to merge 1 commit intocodeigniter4:4.8from
memleakd wants to merge 1 commit intocodeigniter4:4.8from
Conversation
- explain why external side effects should be deferred until commit - add afterCommit and afterRollback examples - clarify Model callbacks are not commit-aware by themselves Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
michalsn
approved these changes
May 4, 2026
ddevsr
approved these changes
May 4, 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.
Description
This PR proposes adding practical documentation for deferring side effects with database transaction callbacks.
It expands the transaction callback docs with examples for:
afterCommit()for side effects that should only run after committed data is visibleafterRollback()for cleanup that should only run when a transaction does not commitMotivation
The
afterCommit()andafterRollback()APIs are useful for avoiding subtle consistency issues around database transactions.For example, application code may need to dispatch a job, trigger an event, clear a cache entry, send a notification, or clean up a temporary file. If that work runs before the surrounding transaction finishes, it may observe data that is not committed yet, or it may run even though the transaction later rolls back.
This documentation gives users a small set of copyable recipes for those cases.
Checklist