Skip to content

Commit

Permalink
Merge pull request #22402 from eileenmcnaughton/no_rel
Browse files Browse the repository at this point in the history
Clarify contents of ids for further fixes
  • Loading branch information
eileenmcnaughton authored Jan 7, 2022
2 parents 9ea6ff4 + dab33b3 commit 1cb8c1e
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1cb8c1e

Please sign in to comment.