mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #10874] Emit postFlush events as the very last thing in UoW::flush()
#12671
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10874
State: closed
Merged: No
This PR moves the
postFlushevent dispatching after final clean-up steps inUnitOfWork::commit().The idea is that at this time,
commit()is "as done as it gets", and it might be possible to callEntityManager::flush()again from event listeners – we'd return from that method on the very next line, and everything would be in the same state if users dediced to callflush()again themselves.Obviously, infinite recursion is one thing either the ORM or users would need to think about.
The intent is to make it somehow possible for users to have event listeners that get notified e. g. through
postPersistto prepare "cascading" changes. These changes could be collected and applied in apostFlushlistener, which might then callflush()again.This sparked off from #10869, where the reporting user is calling
flush()even frompostPersist– a questionable practice, probably never endorsed but it "somehow worked" until 2.16.0.⚠️ BC Break: If
postFlushlisteners inspect UoW state through methods likeisSchedulesForInsertorgetEntityChangeSet, this information will no longer available with this change. → Maybe we need an additional event?