mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Allow to lock entity with EntityManager#refresh() #7038
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 @michnovka on GitHub (Sep 11, 2022).
Feature Request
Recently I stumbled upon how useless the
EntityManager#lock()method is in scenarios where you need up-to-date data during transaction.Now the way to go is to use
$entity = $em->find($entity->id, LockMode::PESSIMISTIC_WRITE);It would be nice and more readable if we would allow to call
EntityManager#refresh()and specify lockMode to acquire a lock on already loaded entity whilst making sure we have the latest version of it at runtime.Summary
I would like to extend the
EntityManager#refresh()to:This will require similar change to
UnitOfWork#refresh()signature, but otherwise should be a simple feature to implement.What do you think?