mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
EntityManager find with pessimistic lock does not check for transaction when cached #5885
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @madwizard-thomas on GitHub (Feb 15, 2018).
Originally assigned to: @Majkl578, @Ocramius on GitHub.
When a pessimistic lock mode is passed to EntityManager::find it normally throws a TransactionRequiredException if no transaction is currently active.
However if the entity is currently in the identity map, it will refresh the entity from the database and return it but not check if a transaction is running. The refresh query has 'FOR UPDATE' (in case of pessimistic write) but this has no effect since there is no transaction.
To reproduce:
Tested with doctrine 2.5.14 but latest code seems to have the same issue.
@Ocramius commented on GitHub (Feb 15, 2018):
Is this a MySQL specific problem?
On 15 Feb 2018 20:22, "Thomas" notifications@github.com wrote:
@madwizard-thomas commented on GitHub (Feb 15, 2018):
I don't think so, but have only tested it with MySQL. It seems to be caused by the early return statement here before the transaction check here
@BreiteSeite commented on GitHub (Feb 17, 2018):
Thanks @madwizard-thomas for the minimal code to reproduce. Helped a lot.
@Ocramius i added this as a test for the test-suite and also provided a fix in #7075
@Ocramius commented on GitHub (Jul 3, 2018):
Handled in #7075 and #7291