DDC-1498: Wrong behavior in getIdentifierValues with null fields #1879

Closed
opened 2026-01-22 13:29:26 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 19, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user stof:

When an identifier field is null, getIdentifierValues will not include it in the returned array: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadata.php#L125

This will lead to a PHP warning when using $repository->find($classMatadata->getIdentifierValues($object)) because there is not the good number of elements in the array. And btw, the array should be validated instead of letting array_combine complain as it does not explain what went wrong: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityRepository.php#L122

This issue was found in https://github.com/symfony/symfony/issues/2670

Originally created by @doctrinebot on GitHub (Nov 19, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user stof: When an identifier field is null, getIdentifierValues will not include it in the returned array: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadata.php#L125 This will lead to a PHP warning when using `$repository->find($classMatadata->getIdentifierValues($object))` because there is not the good number of elements in the array. And btw, the array should be validated instead of letting array_combine complain as it does not explain what went wrong: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/EntityRepository.php#L122 This issue was found in https://github.com/symfony/symfony/issues/2670
admin added the Bug label 2026-01-22 13:29:26 +01:00
admin closed this issue 2026-01-22 13:29:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 22, 2011):

Comment created by @beberlei:

Looks fishy yes, i will look into it.

@doctrinebot commented on GitHub (Nov 22, 2011): Comment created by @beberlei: Looks fishy yes, i will look into it.
Author
Owner

@doctrinebot commented on GitHub (Dec 1, 2011):

Comment created by @beberlei:

This is required from the internals of Doctrine to work this way as its a way to detect if the entity even has identifiers (is new or known).

The Symfony code to load entities has to catch this.

@doctrinebot commented on GitHub (Dec 1, 2011): Comment created by @beberlei: This is required from the internals of Doctrine to work this way as its a way to detect if the entity even has identifiers (is new or known). The Symfony code to load entities has to catch this.
Author
Owner

@doctrinebot commented on GitHub (Dec 1, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Dec 1, 2011): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Dec 1, 2011):

Comment created by stof:

at least, you should throw an exception in find() when the given data is invalid instead of letting array_combine throw a warning (which cannot be catched when you are not using an error handler transforming it to an exception)

@doctrinebot commented on GitHub (Dec 1, 2011): Comment created by stof: at least, you should throw an exception in find() when the given data is invalid instead of letting array_combine throw a warning (which cannot be catched when you are not using an error handler transforming it to an exception)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1879