diff --git a/CRM/Dedupe/BAO/DedupeRuleGroup.php b/CRM/Dedupe/BAO/DedupeRuleGroup.php index 8fa7e35033a2..6faf28ce7988 100644 --- a/CRM/Dedupe/BAO/DedupeRuleGroup.php +++ b/CRM/Dedupe/BAO/DedupeRuleGroup.php @@ -59,7 +59,7 @@ public function setContactIds($contactIds) { * @return array * a table-keyed array of field-keyed arrays holding supported fields' titles */ - public static function supportedFields($requestedType) { + public static function supportedFields($requestedType): array { if (!isset(Civi::$statics[__CLASS__]['supportedFields'])) { // this is needed, as we're piggy-backing importableFields() below $replacements = [ diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index e4ee36ff30f6..7b276158a40f 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -262,39 +262,37 @@ public static function formatParams($fields, $ctype) { } $params = []; - $supportedFields = CRM_Dedupe_BAO_DedupeRuleGroup::supportedFields($ctype); - if (is_array($supportedFields)) { - foreach ($supportedFields as $table => $fields) { - if ($table === 'civicrm_address') { - // for matching on civicrm_address fields, we also need the location_type_id - $fields['location_type_id'] = ''; - // FIXME: we also need to do some hacking for id and name fields, see CRM-3902’s comments - $fixes = [ - 'address_name' => 'name', - 'country' => 'country_id', - 'state_province' => 'state_province_id', - 'county' => 'county_id', - ]; - foreach ($fixes as $orig => $target) { - if (!empty($flat[$orig])) { - $params[$table][$target] = $flat[$orig]; - } + + foreach (CRM_Dedupe_BAO_DedupeRuleGroup::supportedFields($ctype) as $table => $fields) { + if ($table === 'civicrm_address') { + // for matching on civicrm_address fields, we also need the location_type_id + $fields['location_type_id'] = ''; + // FIXME: we also need to do some hacking for id and name fields, see CRM-3902’s comments + $fixes = [ + 'address_name' => 'name', + 'country' => 'country_id', + 'state_province' => 'state_province_id', + 'county' => 'county_id', + ]; + foreach ($fixes as $orig => $target) { + if (!empty($flat[$orig])) { + $params[$table][$target] = $flat[$orig]; } } - if ($table === 'civicrm_phone') { - $fixes = [ - 'phone' => 'phone_numeric', - ]; - foreach ($fixes as $orig => $target) { - if (!empty($flat[$orig])) { - $params[$table][$target] = $flat[$orig]; - } + } + if ($table === 'civicrm_phone') { + $fixes = [ + 'phone' => 'phone_numeric', + ]; + foreach ($fixes as $orig => $target) { + if (!empty($flat[$orig])) { + $params[$table][$target] = $flat[$orig]; } } - foreach ($fields as $field => $title) { - if (!empty($flat[$field])) { - $params[$table][$field] = $flat[$field]; - } + } + foreach ($fields as $field => $title) { + if (!empty($flat[$field])) { + $params[$table][$field] = $flat[$field]; } } }