DDC-2871: preFlush event called multiple times in event manager. #3582

Closed
opened 2026-01-22 14:23:11 +01:00 by admin · 8 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 25, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user strate:

preFlush event called multiple times inside event manager when flushing more than one entity.

Originally created by @doctrinebot on GitHub (Dec 25, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user strate: preFlush event called multiple times inside event manager when flushing more than one entity.
admin added the Bug label 2026-01-22 14:23:12 +01:00
admin closed this issue 2026-01-22 14:23:12 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 25, 2013):

@doctrinebot commented on GitHub (Dec 25, 2013): - duplicates [DDC-2692: [GH-794] Multiple invokation of listeners on PreFlush event](http://www.doctrine-project.org/jira/browse/DDC-2692)
Author
Owner

@doctrinebot commented on GitHub (Dec 25, 2013):

Comment created by @beberlei:

preFlush is called for every entity, you can retrieve the entity affected by using "getEntity()" on the event arguments. Use "onFlush" to get an evvent that is only called once.

@doctrinebot commented on GitHub (Dec 25, 2013): Comment created by @beberlei: preFlush is called for every entity, you can retrieve the entity affected by using "getEntity()" on the event arguments. Use "onFlush" to get an evvent that is only called once.
Author
Owner

@doctrinebot commented on GitHub (Dec 25, 2013):

Comment created by strate:

Benjamin,

  1. It is not documented: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preflush
  2. There is no method "getEntity()" in the event arguments class. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Event/PreFlushEventArgs.php
  3. It is very unexpectable behaviour. Inside event listener (not entity listener) event should called once time per calling "flush()" method of the entity manager.
  4. It can be fixed very simple, I will provide you pull-request soon.
@doctrinebot commented on GitHub (Dec 25, 2013): Comment created by strate: Benjamin, 1. It is not documented: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preflush 2. There is no method "getEntity()" in the event arguments class. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Event/PreFlushEventArgs.php 3. It is very unexpectable behaviour. Inside event listener (not entity listener) event should called once time per calling "flush()" method of the entity manager. 4. It can be fixed very simple, I will provide you pull-request soon.
Author
Owner

@doctrinebot commented on GitHub (Dec 25, 2013):

Comment created by @beberlei:

Ok, the problem is as it seems, there is a "preFlush" lifecycle event that is called for every entity, but also a preFlush listener event that isonly called once. I didn't know that there were sementical differences between them. This indeed needs to be fixed.

@doctrinebot commented on GitHub (Dec 25, 2013): Comment created by @beberlei: Ok, the problem is as it seems, there is a "preFlush" lifecycle event that is called for every entity, but also a preFlush listener event that isonly called once. I didn't know that there were sementical differences between them. This indeed needs to be fixed.
Author
Owner

@doctrinebot commented on GitHub (Dec 25, 2013):

Comment created by strate:

Fix provided here: https://github.com/doctrine/doctrine2/pull/887

@doctrinebot commented on GitHub (Dec 25, 2013): Comment created by strate: Fix provided here: https://github.com/doctrine/doctrine2/pull/887
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-887] was closed:
https://github.com/doctrine/doctrine2/pull/887

@doctrinebot commented on GitHub (Jan 2, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-887] was closed: https://github.com/doctrine/doctrine2/pull/887
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (Jan 2, 2014): Issue was closed with resolution "Duplicate"
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Comment created by @beberlei:

see DDC-2692

@doctrinebot commented on GitHub (Jan 2, 2014): Comment created by @beberlei: see [DDC-2692](http://www.doctrine-project.org/jira/browse/DDC-2692)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3582