From cbd2affa4b053e417e8916f497046cb11103b42b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Jan 2022 09:49:12 +1300 Subject: [PATCH] [REF] Simplify handing of ids Rather than compile contactID into an array to pass it in pass as itself. It is then clear that ids['relationship'] will always be null - so remove the check --- CRM/Contact/BAO/Contact/Utils.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 6e7fdaa6d8..4399d2f345 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -275,7 +275,6 @@ WHERE id IN ( $idString ) } if ($organization && is_numeric($organization)) { - $cid = ['contact' => $contactID]; // get the relationship type id of "Employee of" $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b'); @@ -289,8 +288,8 @@ WHERE id IN ( $idString ) 'relationship_type_id' => $relTypeId . '_a_b', 'contact_check' => [$organization => TRUE], ]; - list($valid, $invalid, $duplicate, $saved, $relationshipIds) - = self::legacyCreateMultiple($relationshipParams, $cid); + [$valid, $invalid, $duplicate, $saved, $relationshipIds] + = self::legacyCreateMultiple($relationshipParams, $contactID); // In case we change employer, clean previous employer related records. if (!$previousEmployerID && !$newContact) { @@ -322,18 +321,17 @@ WHERE id IN ( $idString ) * * @param array $params * (reference ) an assoc array of name/value pairs. - * @param array $ids - * The array that holds all the db ids. - * per http://wiki.civicrm.org/confluence/display/CRM/Database+layer - * "we are moving away from the $ids param " + * @param int $contactID * * @return array * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ - private static function legacyCreateMultiple(&$params, $ids = []) { + private static function legacyCreateMultiple(&$params, int $contactID) { $valid = $invalid = $duplicate = $saved = 0; $relationships = $relationshipIds = []; - $relationshipId = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params)); + $ids = ['contact' => $contactID]; + $relationshipId = CRM_Utils_Array::value('id', $params); //CRM-9015 - the hooks are called here & in add (since add doesn't call create) // but in future should be tidied per ticket -- 2.25.1