Skip to content

Commit

Permalink
Remove legacyCreateMultiple function
Browse files Browse the repository at this point in the history
This was annotated deprecated 7 years ago, is called 'legacy' and was nosily deprecated 10 months
ago. It IS still called from one jma extenion but I think it's OK to remove with a ping
  • Loading branch information
eileenmcnaughton committed Nov 26, 2022
1 parent df23aec commit b45959f
Showing 1 changed file with 0 additions and 79 deletions.
79 changes: 0 additions & 79 deletions CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,85 +141,6 @@ public static function createMultiple($params, $primaryContactLetter) {
];
}

/**
* Only called from import now... plus one place outside of core & tests.
*
* @todo - deprecate more aggressively - will involve copying to the import
* class, adding a deprecation notice here & removing from tests.
*
* Takes an associative array and creates a relationship object.
*
* @deprecated For single creates use the api instead (it's tested).
* For multiple a new variant of this function needs to be written and migrated to as this is a bit
* nasty
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $ids
* The array that holds all the db ids.
* per http://wiki.civicrm.org/confluence/display/CRM/Database+layer
* "we are moving away from the $ids param "
*
* @return array
* @throws \CRM_Core_Exception
*/
public static function legacyCreateMultiple($params, $ids = []) {
CRM_Core_Error::deprecatedFunctionWarning('api v4');
// 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.
$contactID = $ids['contact'];
unset($ids);
// There is only ever one value passed in from the 2 places above that call
// this - by clarifying here like this we can cleanup within this
// function without having to do more universe searches.
$relatedContactID = key($params['contact_check']);

// check if the relationship is valid between contacts.
// step 1: check if the relationship is valid if not valid skip and keep the count
// step 2: check the if two contacts already have a relationship if yes skip and keep the count
// step 3: if valid relationship then add the relation and keep the count

// step 1
[$contactFields['relationship_type_id'], $firstLetter, $secondLetter] = explode('_', $params['relationship_type_id']);
$contactFields['contact_id_' . $firstLetter] = $contactID;
$contactFields['contact_id_' . $secondLetter] = $relatedContactID;
if (!CRM_Contact_BAO_Relationship::checkRelationshipType($contactFields['contact_id_a'], $contactFields['contact_id_b'],
$contactFields['relationship_type_id'])) {
return [0, 0];
}

//CRM-16978:check duplicate relationship as per case id.
// https://issues.civicrm.org/jira/browse/CRM-16978
if ($caseId = CRM_Utils_Array::value('case_id', $params)) {
CRM_Core_Error::deprecatedWarning('this code is believed to be unreachable');
$contactFields['case_id'] = $caseId;
}
if (
self::checkDuplicateRelationship(
$contactFields,
(int) $contactID,
// step 2
(int) $relatedContactID
)
) {
return [0, 1];
}

$singleInstanceParams = array_merge($params, $contactFields);
$relationship = self::add($singleInstanceParams);

// do not add to recent items for import, CRM-4399
if (empty($params['skipRecentView'])) {
self::addRecent($params, $relationship);
}

return [1, 0];
}

/**
* This is the function that check/add if the relationship created is valid.
*
Expand Down

0 comments on commit b45959f

Please sign in to comment.