mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1498: Wrong behavior in getIdentifierValues with null fields #1879
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?
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#L122This issue was found in https://github.com/symfony/symfony/issues/2670
@doctrinebot commented on GitHub (Nov 22, 2011):
Comment created by @beberlei:
Looks fishy yes, i will look into it.
@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):
Issue was closed with resolution "Invalid"
@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)