mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1740: EntityRepository::find throws "The identifier id is missing for a query" when argument with null value is passed (backward compatibility break) #2188
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 (Mar 30, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user disago:
Bug was introduced in commit https://github.com/doctrine/doctrine2/commit/619a31913a4f5952248a0b909a25c2020619c29f.
If a variable with null value is passed to a repository find() method the exception is thrown because isset() is used instead of array_key_exists() to check for a valid identifier key (and isset returns false when the variable has null). This introduces a BC break in current scenarios that expected that doing a find($variableWithNullValue) should return null instead of raising an exception.
Should be:
@doctrinebot commented on GitHub (Mar 30, 2012):
Comment created by disago:
Patch attached
@doctrinebot commented on GitHub (Mar 30, 2012):
Comment created by @beberlei:
Its a BC break, but the previous behavior is invalid. The method expects an identifier, which by definition cannot be null.
@doctrinebot commented on GitHub (Mar 30, 2012):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/20b09dd46a7fcb12a4bf
@andho commented on GitHub (Jul 8, 2016):
"Argument 1 passed to
findshould not be null." would be a more appropriate exception.@Ocramius commented on GitHub (Jul 8, 2016):
find()allows an array of values to be passed in. If any of the identifier fields passed tofind()isnull, then it should fail.missingIdentifierFieldis what is closest (semantically) to this behavior. Feel free to send a patch with an improved error message though.