From dab33b3758eec504f75d34b4f439552cfcb81687 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 7 Jan 2022 14:37:47 +1300 Subject: [PATCH] Clarify contents of ids for further fixes --- CRM/Contact/BAO/Relationship.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index dd94e3daa230..76b25e760abc 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -165,26 +165,23 @@ public static function createMultiple($params, $primaryContactLetter) { public static function legacyCreateMultiple(&$params, $ids = []) { $valid = $invalid = $duplicate = $saved = 0; $relationships = $relationshipIds = []; - $relationshipId = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params)); - - //CRM-9015 - the hooks are called here & in add (since add doesn't call create) + // clarify that the only key ever pass in the ids array is 'contact' + // There is legacy handling for other keys but a universe search on + // calls to this function (not supported to be called from outside core) + // only returns 2 calls - one in CRM_Contact_Import_Parser_Contact + // and the other in jma grant applications (CRM_Grant_Form_Grant_Confirm) + // both only pass in contact as a key here. + $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 - if (empty($relationshipId)) { - $hook = 'create'; - } - else { - $hook = 'edit'; - } - // @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 - $dataExists = self::dataExists($params); - if (!$dataExists) { - return [FALSE, TRUE, FALSE, FALSE, NULL]; - } $relationshipIds = []; foreach ($params['contact_check'] as $key => $value) { // check if the relationship is valid between contacts.