$relationship = CRM_Core_DAO::executeQuery($queryString);
while ($relationship->fetch()) {
// Check whether the custom field values are identical.
- $result = self::checkDuplicateCustomFields($params, $relationship->id);
- if ($result) {
+ if (self::checkDuplicateCustomFields($params['custom'] ?? [], $relationship->id)) {
return TRUE;
}
}
* the same as the values of the custom fields of the relation with given
* $relationshipId.
*
- * @param array $params (reference) an assoc array of name/value pairs
+ * @param array $params an assoc array of name/value pairs
* @param int $relationshipId ID of an existing duplicate relation
*
* @return boolean true if custom field values are identical
* @access private
* @static
*/
- private static function checkDuplicateCustomFields(&$params, $relationshipId) {
+ private static function checkDuplicateCustomFields($params, $relationshipId) {
// Get the custom values of the existing relationship.
$existingValues = CRM_Core_BAO_CustomValueTable::getEntityValues($relationshipId, 'Relationship');
// Create a similar array for the new relationship.
$newValues = [];
- if (isset($params['custom']) && is_array($params['custom'])) {
- // $params['custom'] seems to be an array. Each value is again an array.
+ if (!is_array($params)) {
+ // No idea when this would happen....
+ CRM_Core_Error::deprecatedWarning('params should be an array');
+ }
+ else {
+ // $params seems to be an array, as it should be. Each value is again an array.
// This array contains one value (key -1), and this value seems to be
// an array with the information about the custom value.
- foreach ($params['custom'] as $value) {
+ foreach ($params as $value) {
foreach ($value as $customValue) {
$newValues[$customValue['custom_field_id']] = $customValue['value'];
}