From: Eileen McNaughton Date: Thu, 6 Jan 2022 21:30:09 +0000 (+1300) Subject: [REF] Rename variable to be meaningful X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d6979a54aab34ba919038335a86fd9519cbc7bb7;p=civicrm-core.git [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 --- diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index f3679cab81..aac605be19 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -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++; diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index 502f6b143a..fbc7a3bfaf 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -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++;