(Regression) Strict typing on CRM_Contact_BAO_Contact::getDuplicateContacts() causes fatal error
PR 22394 adds strict type checking, which causes a fatal error with inputs that were previously acceptable.
Steps to replicate
Run cv api Contact.duplicatecheck
with no arguments.
Result in 5.45
{
"is_error": 0,
"version": 3,
"count": 0,
"values": []
}
Result in 5.46
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Argument 1 passed to CRM_Contact_BAO_Contact::getDuplicateContacts() must be of the type array, null given, called in /home/jon/local/civicrm-buildkit/build/dmaster/web/sites/all/modules/civicrm/api/v3/Contact.php on line 1611
Now, passing no arguments should arguably not be supported, but a typical usage is to leave the rule type undefined, which defaults to Unsupervised
. Now, leaving it undefined gives an error of "Argument 3 must be a string, null given".
Since this is a bug that will bite a lot of folks, I'm going to do a quick PR to allow these arguments to be nullable - but I imagine in the long term we want to modify the calling functions to pass valid values. Though I think that argument 3 ($rule
) should always be nullable.