From d6979a54aab34ba919038335a86fd9519cbc7bb7 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Jan 2022 10:30:09 +1300 Subject: [PATCH] [REF] Rename variable to be meaningful 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 | 8 ++++---- CRM/Contact/BAO/Relationship.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index f3679cab81f0..aac605be1970 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -328,15 +328,15 @@ private static function legacyCreateMultiple(&$params, int $contactID) { $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 @@ private static function legacyCreateMultiple(&$params, int $contactID) { $contactFields, CRM_Utils_Array::value('contact', $ids), // step 2 - $key + $organizationID ) ) { $duplicate++; diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 502f6b143ae1..fbc7a3bfaff2 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -178,15 +178,15 @@ public static function legacyCreateMultiple(&$params, $ids = []) { 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 @@ public static function legacyCreateMultiple(&$params, $ids = []) { $contactFields, CRM_Utils_Array::value('contact', $ids), // step 2 - $key + $relatedContactID ) ) { $duplicate++;