From 7eab7e49d9d382aa08bb931bf771657532c65c99 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Jan 2022 13:08:26 +1300 Subject: [PATCH] Ensure getDuplicateContacts always returns an array Calling code already handles an empty array as that is what it would receive - unless the hook set it to NULL --- CRM/Contact/BAO/Contact.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 916a21f7c8..9cbbb6567b 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -3572,8 +3572,9 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id ) * The context if relevant, eg. ['event_id' => X] * * @return array + * @throws \CRM_Core_Exception */ - public static function getDuplicateContacts($input, $contactType, $rule = 'Unsupervised', $excludedContactIDs = [], $checkPermissions = TRUE, $ruleGroupID = NULL, $contextParams = []) { + public static function getDuplicateContacts(array $input, string $contactType, string $rule = 'Unsupervised', $excludedContactIDs = [], $checkPermissions = TRUE, $ruleGroupID = NULL, $contextParams = []): array { $dedupeParams = CRM_Dedupe_Finder::formatParams($input, $contactType); $dedupeParams['check_permission'] = $checkPermissions; $dedupeParams['contact_type'] = $contactType; @@ -3586,7 +3587,7 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id ) if (!$dedupeResults['handled']) { $dedupeResults['ids'] = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $contactType, $rule, $excludedContactIDs, $ruleGroupID); } - return $dedupeResults['ids']; + return $dedupeResults['ids'] ?? []; } /** -- 2.25.1