`-ing` Observer events fire after changes are persisted if `ShouldHandleEventsAfterCommit` or `$afterCommit = true` is present
Laravel Version
11.45.1
PHP Version
8.3.8
Database Driver & Version
No response
Description
-ing events such as updating, creating and deleting still fire after the transaction commits if ShouldHandleEventsAfterCommit is implemented or $afterCommit = true property is present on the Observer.
The documentation states that these events fire before changes are persisted, but in the case where ShouldHandleEventsAfterCommit is implemented or $afterCommit = true property is present on the Observer, these events fire after changes are persisted.
I think the documentation should at least clearly clarify this behaviour.
In my opinion -ing events should be excluded from this behaviour entirely. I don't believe there is any logical use case for -ing events to fire this way - it makes them redundant as they effectively just become -ed events.
Steps To Reproduce
- Set up an observer for a model that implements
ShouldHandleEventsAfterCommitor has$afterCommit = trueproperty - Listen for
-ingevents - Trigger an
-ingevent - Inspect the model and notice that changes have been persisted