From e995b80f53563c797585f798f42a8cc098eb14a8 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Jan 2022 09:52:17 +1300 Subject: [PATCH] [REF] Remove handling for relationshipID We can see that the only call to this function does not set params['id'] & hence it is NULL --- CRM/Contact/BAO/Contact/Utils.php | 47 ++----------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 4399d2f345..7b5d72ef71 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -331,17 +331,11 @@ WHERE id IN ( $idString ) $valid = $invalid = $duplicate = $saved = 0; $relationships = $relationshipIds = []; $ids = ['contact' => $contactID]; - $relationshipId = CRM_Utils_Array::value('id', $params); + $relationshipId = NULL; //CRM-9015 - the hooks are called here & in add (since add doesn't call create) // but in future should be tidied per ticket - if (empty($relationshipId)) { - $hook = 'create'; - } - else { - $hook = 'edit'; - } - + $hook = 'create'; // @todo pre hook is called from add - remove it from here CRM_Utils_Hook::pre($hook, 'Relationship', $relationshipId, $params); @@ -390,43 +384,6 @@ WHERE id IN ( $idString ) } // editing the relationship } - else { - // check for duplicate relationship - // @todo this code doesn't cope well with updates - causes e-Notices. - // API has a lot of code to work around - // this but should review this code & remove the extra handling from the api - // it seems doubtful any of this is relevant if the contact fields & relationship - // type fields are not set - if ( - CRM_Contact_BAO_Relationship::checkDuplicateRelationship( - $params, - CRM_Utils_Array::value('contact', $ids), - $ids['contactTarget'], - $relationshipId - ) - ) { - $duplicate++; - return [$valid, $invalid, $duplicate, $saved, NULL]; - } - - $validContacts = TRUE; - //validate contacts in update mode also. - $contactFields = CRM_Contact_BAO_Relationship::setContactABFromIDs($params, $ids, $ids['contactTarget']); - if (!empty($ids['contact']) && !empty($ids['contactTarget'])) { - if (CRM_Contact_BAO_Relationship::checkValidRelationship($contactFields, $ids, $ids['contactTarget'])) { - $validContacts = FALSE; - $invalid++; - } - } - if ($validContacts) { - // editing an existing relationship - $singleInstanceParams = array_merge($params, $contactFields); - $relationship = CRM_Contact_BAO_Relationship::add($singleInstanceParams, $ids, $ids['contactTarget']); - $relationshipIds[] = $relationship->id; - $relationships[$relationship->id] = $relationship; - $saved++; - } - } // do not add to recent items for import, CRM-4399 if (!(!empty($params['skipRecentView']) || $invalid || $duplicate)) { -- 2.25.1