Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 8 comments

2 participants

@doctrinebot

Jira issue originally created by user strate:

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

@doctrinebot

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

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

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

Comment created by strate:

Fix provided here: #887

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-887] was closed:
#887

@doctrinebot

Issue was closed with resolution "Duplicate"

@doctrinebot

Comment created by @beberlei:

see DDC-2692

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.