[REF] Rename variable to be meaningful
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 6 Jan 2022 21:30:09 +0000 (10:30 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sun, 9 Jan 2022 04:45:30 +0000 (17:45 +1300)
It turns out key is organizationID - rename ...

I did this in both places the function is called from - as I clean up the copy some
cleanups on the original emerge too

CRM/Contact/BAO/Contact/Utils.php
CRM/Contact/BAO/Relationship.php

index f3679cab81f01d4fa2d3b63c6d39a37be8835408..aac605be1970cd0c92888b030051915e22d791d3 100644 (file)
@@ -328,15 +328,15 @@ WHERE  id IN ( $idString )
     $ids = ['contact' => $contactID];
 
     $relationshipIds = [];
-    foreach ($params['contact_check'] as $key => $value) {
+    foreach (array_keys($params['contact_check']) as $organizationID) {
       // check if the relationship is valid between contacts.
       // step 1: check if the relationship is valid if not valid skip and keep the count
       // step 2: check the if two contacts already have a relationship if yes skip and keep the count
       // step 3: if valid relationship then add the relation and keep the count
 
       // step 1
-      $contactFields = CRM_Contact_BAO_Relationship::setContactABFromIDs($params, $ids, $key);
-      $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($contactFields, $ids, $key);
+      $contactFields = CRM_Contact_BAO_Relationship::setContactABFromIDs($params, $ids, $organizationID);
+      $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($contactFields, $ids, $organizationID);
       if ($errors) {
         $invalid++;
         continue;
@@ -347,7 +347,7 @@ WHERE  id IN ( $idString )
           $contactFields,
           CRM_Utils_Array::value('contact', $ids),
           // step 2
-          $key
+          $organizationID
         )
       ) {
         $duplicate++;
index 502f6b143ae14d44fc5ce2052fdc06b61e09e6f2..fbc7a3bfaff2c8a7790a1d2b3d3203e00fc5800c 100644 (file)
@@ -178,15 +178,15 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
     if (!$relationshipId) {
       // creating a new relationship
       $relationshipIds = [];
-      foreach ($params['contact_check'] as $key => $value) {
+      foreach (array_keys($params['contact_check']) as $relatedContactID) {
         // check if the relationship is valid between contacts.
         // step 1: check if the relationship is valid if not valid skip and keep the count
         // step 2: check the if two contacts already have a relationship if yes skip and keep the count
         // step 3: if valid relationship then add the relation and keep the count
 
         // step 1
-        $contactFields = self::setContactABFromIDs($params, $ids, $key);
-        $errors = self::checkValidRelationship($contactFields, $ids, $key);
+        $contactFields = self::setContactABFromIDs($params, $ids, $relatedContactID);
+        $errors = self::checkValidRelationship($contactFields, $ids, $relatedContactID);
         if ($errors) {
           $invalid++;
           continue;
@@ -203,7 +203,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
           $contactFields,
           CRM_Utils_Array::value('contact', $ids),
           // step 2
-          $key
+          $relatedContactID
         )
         ) {
           $duplicate++;