From e754a143662ccf747e656872b4460b40f0b812eb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 22 Aug 2022 12:10:08 +1200 Subject: [PATCH] Remove extraneous if (supportedFields always returns an array --- CRM/Dedupe/BAO/DedupeRuleGroup.php | 2 +- CRM/Dedupe/Finder.php | 56 ++++++++++++++---------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/CRM/Dedupe/BAO/DedupeRuleGroup.php b/CRM/Dedupe/BAO/DedupeRuleGroup.php index 8fa7e35033..6faf28ce79 100644 --- a/CRM/Dedupe/BAO/DedupeRuleGroup.php +++ b/CRM/Dedupe/BAO/DedupeRuleGroup.php @@ -59,7 +59,7 @@ class CRM_Dedupe_BAO_DedupeRuleGroup extends CRM_Dedupe_DAO_DedupeRuleGroup { * @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 e4ee36ff30..7b276158a4 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -262,39 +262,37 @@ class CRM_Dedupe_Finder { } $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]; } } } -- 2.25.1