[REF] Remove handling for relationshipID
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 6 Jan 2022 20:52:17 +0000 (09:52 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 6 Jan 2022 23:21:07 +0000 (12:21 +1300)
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

index 4399d2f3456e1828aca7d9c854fe0cabb391532e..7b5d72ef71de04cbdd65c26a912eff89be01a604 100644 (file)
@@ -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)) {