Skip to content

Commit

Permalink
Merge pull request civicrm#24339 from eileenmcnaughton/sup_fields
Browse files Browse the repository at this point in the history
Remove extraneous `if` (`supportedFields` always returns an array)
  • Loading branch information
eileenmcnaughton authored Aug 22, 2022
2 parents cafaffb + e754a14 commit e20ffe3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CRM/Dedupe/BAO/DedupeRuleGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
56 changes: 27 additions & 29 deletions CRM/Dedupe/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}
Expand Down

0 comments on commit e20ffe3

Please sign in to comment.