Stop calling hook twice
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 7 Jan 2022 03:05:58 +0000 (16:05 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 7 Jan 2022 06:35:46 +0000 (19:35 +1300)
Per the code comments this hook is called here but also in add. This is all about the crazy
history of this function - which used to be tied to the relationship form.

I can't think of any valid use for calling the hook twice - but I can think of reasons it
would be bad...

CRM/Contact/BAO/Contact/Utils.php
CRM/Contact/BAO/Relationship.php

index fbc52b4daa0460ed28d135fd31080b53486e4c87..f5d05331e7ea6f9ccb2ef4bb49dba1b5ed970a9d 100644 (file)
@@ -332,12 +332,6 @@ WHERE  id IN ( $idString )
     $relationships = $relationshipIds = [];
     $ids = ['contact' => $contactID];
 
-    //CRM-9015 - the hooks are called here & in add (since add doesn't call create)
-    // but in future should be tidied per ticket
-    $hook = 'create';
-    // @todo pre hook is called from add - remove it from here
-    CRM_Utils_Hook::pre($hook, 'Relationship', NULL, $params);
-
     // creating a new relationship
     $dataExists = CRM_Contact_BAO_Relationship::dataExists($params);
     if (!$dataExists) {
index b2972fb4868c2bd4109bbb4bb06de04f5269ee3b..418f2218c75dfd94b811195317f05acfed3fdef8 100644 (file)
@@ -174,11 +174,6 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
     $ids = ['contact' => $ids['contact']];
     // Likewise neither place ever passed in relationshipID
     $relationshipId = NULL;
-    $hook = 'create';
-    // CRM-9015 - the hooks are called here & in add (since add doesn't call create)
-    // but in future should be tidied per ticket
-    // @todo pre hook is called from add - remove it from here
-    CRM_Utils_Hook::pre($hook, 'Relationship', $relationshipId, $params);
 
     if (!$relationshipId) {
       // creating a new relationship