Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2871

preFlush event called multiple times in event manager.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker 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
          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
          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
          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
          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
          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
          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
          Artur Eshenbrener added a comment -
          Show
          Artur Eshenbrener added a comment - Fix provided here: https://github.com/doctrine/doctrine2/pull/887
          Hide
          Doctrine Bot added a comment -

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

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: