Skip to content

Fix no-op for initializeObject() and isUnitializedObject() when object is not a mapped entity#12173

Open
SherinBloemendaal wants to merge 1 commit intodoctrine:3.6.xfrom
SherinBloemendaal:fix-initialize-object-for-native-lazy-objects-no-op
Open

Fix no-op for initializeObject() and isUnitializedObject() when object is not a mapped entity#12173
SherinBloemendaal wants to merge 1 commit intodoctrine:3.6.xfrom
SherinBloemendaal:fix-initialize-object-for-native-lazy-objects-no-op

Conversation

@SherinBloemendaal
Copy link

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 after clear()).

I went with the try/catch approach since isInIdentityMap() also internally calls getClassMetadata(), but I'm open to better solutions if there are any.

Changes:

  • UnitOfWork::initializeObject(): Add try/catch around metadata access
  • UnitOfWork::isUninitializedObject(): Add try/catch around metadata access

Fixes #12172

@github-actions
Copy link
Contributor

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions bot added the Stale label Dec 19, 2025
@greg0ire greg0ire requested a review from stof December 19, 2025 07:34
@greg0ire
Copy link
Member

@stof since you introduced the comment on the interface, please review.

@github-actions github-actions bot removed the Stale label Dec 20, 2025
@derrabus derrabus changed the base branch from 3.5.x to 3.6.x December 30, 2025 17:38
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

Successfully merging this pull request may close these issues.

initializeObject() throws exception for non-managed objects with native lazy objects

2 participants