From 2fd72602a6491197f3fa2846357cb8884a963bdc Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 24 Oct 2019 15:37:19 +1300 Subject: [PATCH] [REF] minor refactor towards removing complexity. This change actually makes the foreach & if following it redundant. I left them out for legibility but basically all the wrangling is on the 'other' contact. We do just one thing with the 'main' contact so the whole foreach & if is silly. Will follow up with removal of those --- CRM/Dedupe/Merger.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 5020ac7863..e513265d80 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1091,10 +1091,12 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m // CRM-15681 don't display sub-types in UI continue; } - foreach (['main' => $main, 'other' => $other] as $moniker => $contact) { - list($label, $value) = self::getFieldValueAndLabel($field, $contact); - $rows["move_$field"][$moniker] = $label; + $rows["move_$field"]['main'] = self::getFieldValueAndLabel($field, $main)['label']; + $rows["move_$field"]['other'] = self::getFieldValueAndLabel($field, $other)['label']; + + foreach (['other' => $other] as $moniker => $contact) { if ($moniker == 'other') { + $value = self::getFieldValueAndLabel($field, $other)['value']; //CRM-14334 if ($value === NULL || $value == '') { $value = 'null'; @@ -2524,7 +2526,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m elseif ($field == 'current_employer_id' && !empty($value)) { $label = "$value (" . CRM_Contact_BAO_Contact::displayName($value) . ")"; } - return [$label, $value]; + return ['label' => $label, 'value' => $value]; } /** -- 2.25.1