You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
// $em is EntityManager, Order entity can be any entity$em->find(Order::class, 1); // Load order id 1 in entity map$em->find(Order::class, 1, LockMode::PESSIMISTIC_WRITE); // does not throw exception$em->find(Order::class, 2, LockMode::PESSIMISTIC_WRITE); // throws TransactionRequiredException
Tested with doctrine 2.5.14 but latest code seems to have the same issue.