[REF] minor refactor towards removing complexity.
authoreileen <emcnaughton@wikimedia.org>
Thu, 24 Oct 2019 02:37:19 +0000 (15:37 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 24 Oct 2019 02:37:19 +0000 (15:37 +1300)
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

index 5020ac7863f06d47f11cf0b5e27651bf13caa34a..e513265d807da200ba7bf739747f30e72fec1858 100644 (file)
@@ -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];
   }
 
   /**