Skip to content

Calling entityManager#flush in preFlush event listener causes infinite recursive loop #6857

@egonolieux

Description

@egonolieux

To override the default commit order for collections because of a unique constraint (delete before insert instead of insert before delete), I manually add removed collection items to a separate array inside the entity instead of using orphanRemoval. In a preFlush event listener I call entityManager#remove on each removed collection item followed by entityManager#flush.

However, this seems to cause the preFlush event to be caught in an infinite recursive loop. Although this seems somewhat expected, the documentation says it is safe to call entityManager#flush inside the preFlush event: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preflush, which is why I implemented it anyway.

Is this a mistake in the documentation or could this be a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions