Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-2871

preFlush event called multiple times in event manager.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Duplicate
    • Affects Version/s: Git Master
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

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

        Issue Links

          Activity

          Hide
          beberlei Benjamin Eberlei added a comment -

          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.

          Show
          beberlei Benjamin Eberlei added a comment - 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.
          Hide
          strate Artur Eshenbrener added a comment -

          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.

          Show
          strate Artur Eshenbrener added a comment - 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.
          Hide
          beberlei Benjamin Eberlei added a comment -

          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.

          Show
          beberlei Benjamin Eberlei added a comment - 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.
          Hide
          strate Artur Eshenbrener added a comment -
          Show
          strate Artur Eshenbrener added a comment - Fix provided here: https://github.com/doctrine/doctrine2/pull/887
          Hide
          doctrinebot Doctrine Bot added a comment -

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

          Show
          doctrinebot Doctrine Bot added a comment - A related Github Pull-Request [GH-887] was closed: https://github.com/doctrine/doctrine2/pull/887
          Hide
          beberlei Benjamin Eberlei added a comment -
          Show
          beberlei Benjamin Eberlei added a comment - see DDC-2692

            People

            • Assignee:
              beberlei Benjamin Eberlei
              Reporter:
              strate Artur Eshenbrener
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: