PostFlush event is dispatched before unitofwork is cleanup #6723

Open
opened 2026-01-22 15:37:33 +01:00 by admin · 0 comments
Owner

Originally created by @alexander-schranz on GitHub (May 17, 2021).

Currently the postflush event is dispatched before the unitofwork is cleanup. We tried to add some listener to it but got into some problems because the UnitOfWork was not yet cleanup. The code can be found here:

3a194ad699/lib/Doctrine/ORM/UnitOfWork.php (L378-L380)

3a194ad699/lib/Doctrine/ORM/UnitOfWork.php (L472-L474)

For our case it would be great if the UnitOfWork cleanup is done before dispatching the post events e.g.:

-            $this->dispatchPostFlushEvent();
+            $this->postCommitCleanup($entity);

-            $this->postCommitCleanup($entity);
+            $this->dispatchPostFlushEvent();

I understand that this could be a bc break so an alternative would be add a new postFlushCleanup event which we could listen to it. What do you think?

Originally created by @alexander-schranz on GitHub (May 17, 2021). Currently the postflush event is dispatched before the unitofwork is cleanup. We tried to add some listener to it but got into some problems because the `UnitOfWork` was not yet cleanup. The code can be found here: https://github.com/doctrine/orm/blob/3a194ad69946ec3e4289e50a877f96b8aad8b223/lib/Doctrine/ORM/UnitOfWork.php#L378-L380 https://github.com/doctrine/orm/blob/3a194ad69946ec3e4289e50a877f96b8aad8b223/lib/Doctrine/ORM/UnitOfWork.php#L472-L474 For our case it would be great if the `UnitOfWork` cleanup is done before dispatching the post events e.g.: ```diff - $this->dispatchPostFlushEvent(); + $this->postCommitCleanup($entity); - $this->postCommitCleanup($entity); + $this->dispatchPostFlushEvent(); ``` I understand that this could be a bc break so an alternative would be add a new `postFlushCleanup` event which we could listen to it. What do you think?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6723