mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #6755] EntityManager::getReference() can return null #10122
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?
Original Pull Request: https://github.com/doctrine/orm/pull/6755
State: closed
Merged: Yes
When the requested class has subclasses, a proxy cannot be returned, and the entity has to be loaded from the DB to figure out its actual class:
13f838f8be/lib/Doctrine/ORM/EntityManager.php (L498-L500)Because
find()is used, if the entity doesn't exist,EntityManager::getReference()therefore returnsnull.I think that either:
EntityManagerInterface::getReference()should beobject|nullEntityManager::getReference()should throw anORMExceptionwhen the id doesn't existThis is a PR for the first proposal, but if you prefer the second approach (BC break?) I can change the PR.