mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #12173] Fix no-op for initializeObject() and isUnitializedObject() when object is not a mapped entity #13544
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?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/12173
Author: @SherinBloemendaal
Created: 9/19/2025
Status: 🔄 Open
Base:
3.6.x← Head:fix-initialize-object-for-native-lazy-objects-no-op📝 Commits (1)
788faa0Fix no-op for initializeObject() and isUnitializedObject() when object is not a mapped entity📊 Changes
2 files changed (+96 additions, -3 deletions)
View changed files
📝
src/UnitOfWork.php(+12 -3)➕
tests/Tests/ORM/Functional/Ticket/GH12172Test.php(+84 -0)📄 Description
Fix initializeObject() and isUnitializedObject() to be no-op for non-managed objects with native lazy objects
This fix wraps
getClassMetadata()calls in try/catch blocks to handle non-entity objects gracefully while preserving functionality for valid Doctrine entities (including detached ones afterclear()).I went with the try/catch approach since
isInIdentityMap()also internally callsgetClassMetadata(), but I'm open to better solutions if there are any.Changes:
UnitOfWork::initializeObject(): Add try/catch around metadata accessUnitOfWork::isUninitializedObject(): Add try/catch around metadata accessFixes #12172
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.