Open ToshY opened 1 year ago
What about this code?
When an exception occurs inside UnitOfWork::commit()
, the EM is closed before the exception is re-thrown. Isn't that what you're looking for?
@mpdude I don't think we are on the same page.
Doctrine\DBAL\Connection
. Looking at the Connection
it only performs a rollback, and does not close the entitymanager unlike EntityManager#transactional($func)
, making the following sentence in the documentation incorrect:
https://github.com/doctrine/orm/blob/19db7510a7b49605a9139fc2964342a98a682a8c/docs/en/reference/transactions-and-concurrency.rst?plain=1#L87-L88As it's currently not "funcionally equivalent", I propose to update the documentation to include $em->close()
in the catch block before the rollback, in order to be consistent with the behavior of EntityManager#transactional
as mentioned in the text.
Doesn't the UoW already close the entity manager when an exception is thrown from inside UoW::commit()
?
What I want to say is:
From the user's perspective, you don't have to close the EntityManager, in neither of the two ways. The ORM code will make sure it will be closed.
Bug Report
Summary
Doctrine\DBAL\Connection
API) has lost the part that closes the EntityManager, therefore making it no longer "functionally equivalent" to the subsequent example usingEntityManager#transactional($func)
.Current behavior
Expected behavior