Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection clear UnitOfWork calls DELETE query again on event listener in postFlush and so loses relations #11827

Open
alexander-schranz opened this issue Feb 6, 2025 · 0 comments

Comments

@alexander-schranz
Copy link
Contributor

alexander-schranz commented Feb 6, 2025

Bug Report

Q A
Version 2.17.2, 2.20.2 (tested versions)
Previous Version if the bug is a regression -

Summary

Collection clear UnitOfWork calls DELETE query again on event listener in postFlush and so loses relations.

Current behavior

It seems like the postFlush event the UnitOfWork is not correctly cleaned up and the DELETE query is trigger again.

Image

Expected behavior

DELETE query should only triggered once and not again in additional flush.

How to reproduce

I created a reproducer repository here: https://github.com/alexander-schranz/doctrine-unit-of-work-flush-clear-reproducer

The important file is this one:

https://github.com/alexander-schranz/doctrine-unit-of-work-flush-clear-reproducer/blob/main/src/Controller/TestController.php

Normally this is kind of splitted up in several services:

  • Controller
  • which calls a sync Message via symfony messenger
  • a MessageHandler which does load the entity do the changes and use a custom eventCollector service to add events which dispatcher after entity was saved
  • a Middleware which does the flush
  • a postFLush listener which dispatched the collected events
  • a EventListener which may edit / update other entities and call so flush again

I did avoid this complexity and put the parts into the TestConroller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant