Closed nicolas-grekas closed 1 month ago
I added a test case that breaks if the unitOfWork property is made readonly or if the class is made final.
The readonly modifier has been added as if it had no consequences, but in reality it breaks the possibility to reset the EM, while this is an important capability when using it in long-running processes.
FTR: Resetting the EM is a feature that the ORM neither advertised nor documented. Reopening an EM is explicitly not supported. I'm fine merging this change to unblock downstream projects. But this reset feature should be implemented properly in this repository. We cannot maintain or support features that are monkey-patched onto our code.
I will review this after I find time to read https://github.com/doctrine/orm/issues/5933
This does not fix a bug with Doctrine, and as such should target 3.2.x. We may release 3.2.0 quickly after this is merged as a courtesy to Symfony users.
This does not fix a bug with Doctrine, and as such should target 3.2.x. We may release 3.2.0 quickly after this is merged as a courtesy to Symfony users.
Fine to me :rocket: :shipit: :ship:
We may release 3.2.0 quickly after this is merged as a courtesy to Symfony users.
My mailbox highly appreciates this 😉
@derrabus the feature request to move this feature to the ORM itself exists since 2016: https://github.com/doctrine/orm/issues/5933 Being able to reopen an EntityManager instance (after clearing it to remove the broken state of managed entities) is the only way you can use the ORM in a long running queue consumer as you don't want to kill your long-running process each time an exception happen during the handling of a message.
I think, we both know the difference beware requesting a feature and implementing it. I'm aware that the request exists, bit somebody needs to do it.
The readonly modifier has been added as if it had no consequences, but in reality it breaks the possibility to reset the EM, while this is an important capability when using it in long-running processes.
This has the same reasoning as why
@final
is used and not the real final modifier.Please see the discussion in https://github.com/symfony/symfony/issues/54228 for more detailed explanations.