Skip to content

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

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

1 participant