[PR #7471] Fix parameter value processing for objects with unloaded metadata #10503

Open
opened 2026-01-22 16:07:46 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/7471

State: closed
Merged: Yes


When binding an object as query parameter, the query object normally tries to convert this object into its identifier. This however only happened if class metadata for the object was already loaded. If it wasn't loaded, conversion was skipped leading to wrong results. While getMetadataFor is more performance sensitive than hasMetadataFor, we may not assumed that metadata for the bound object has been loaded yet.

The code has been changed to no longer check the metadata factory and call UnitOfWork::getSingleIdentifierValue directly, ignoring any mapping exception in the process. This preserves behaviour where binding any unmapped object to a query will send the entire object to the database.

**Original Pull Request:** https://github.com/doctrine/orm/pull/7471 **State:** closed **Merged:** Yes --- When binding an object as query parameter, the query object normally tries to convert this object into its identifier. This however only happened if class metadata for the object was already loaded. If it wasn't loaded, conversion was skipped leading to wrong results. While `getMetadataFor` is more performance sensitive than `hasMetadataFor`, we may not assumed that metadata for the bound object has been loaded yet. The code has been changed to no longer check the metadata factory and call `UnitOfWork::getSingleIdentifierValue` directly, ignoring any mapping exception in the process. This preserves behaviour where binding any unmapped object to a query will send the entire object to the database.
admin added the pull-request label 2026-01-22 16:07:46 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#10503