Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to lock entity with EntityManager#refresh() #10039

Closed
michnovka opened this issue Sep 11, 2022 · 0 comments
Closed

Allow to lock entity with EntityManager#refresh() #10039

michnovka opened this issue Sep 11, 2022 · 0 comments

Comments

@michnovka
Copy link
Contributor

michnovka commented 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.

Q A
New Feature yes
RFC no
BC Break no

Summary

I would like to extend the EntityManager#refresh() to:

public function refresh($entity, $lockMode = null)

This will require similar change to UnitOfWork#refresh() signature, but otherwise should be a simple feature to implement.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants