mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
initializeObject() throws exception for non-managed objects with native lazy objects #7555
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 @SherinBloemendaal on GitHub (Sep 19, 2025).
Bug Report
Summary
When
isNativeLazyObjectsEnabled()istrue, callingEntityManager::initializeObject()orUnitOfWork::initializeObject()with a non-managed object throws an exception instead of performing a no-op as specified by theObjectManagerinterface contract.Current behavior
Calling
initializeObject()on objects that are not Doctrine entities results in an exception:This breaks the documented interface contract which states the method should be "a no-op for other objects."
Expected behavior
According to the
ObjectManagerinterface documentation:b0bb31ae05/src/Persistence/ObjectManager.php (L114-L119)The method should silently do nothing when called with non-Doctrine entities, not throw an exception.
How to reproduce