Skip to content

Commit

Permalink
[Import] Unpack the weird error return
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed May 17, 2022
1 parent a4f37d9 commit bb1f622
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions CRM/Utils/DeprecatedUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,33 @@ function _civicrm_api3_deprecated_duplicate_formatted_contact($params) {

if ($contact->find(TRUE)) {
if ($params['contact_type'] != $contact->contact_type) {
return civicrm_api3_create_error("Mismatched contact IDs OR Mismatched contact Types");
return ['is_error' => 1, 'error_message' => 'Mismatched contact IDs OR Mismatched contact Types'];
}

$error = CRM_Core_Error::createError("Found matching contacts: $contact->id",
CRM_Core_Error::DUPLICATE_CONTACT,
'Fatal', $contact->id
);
return civicrm_api3_create_error($error->pop());
return [
'is_error' => 1,
'error_message' => [
'code' => CRM_Core_Error::DUPLICATE_CONTACT,
'params' => [$contact->id],
'level' => 'Fatal',
'message' => "Found matching contacts: $contact->id",
],
];
}
}
else {
$ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $params['contact_type'], 'Unsupervised');

if (!empty($ids)) {
$ids = implode(',', $ids);
$error = CRM_Core_Error::createError("Found matching contacts: $ids",
CRM_Core_Error::DUPLICATE_CONTACT,
'Fatal', $ids
);
return civicrm_api3_create_error($error->pop());
return [
'is_error' => 1,
'error_message' => [
'code' => CRM_Core_Error::DUPLICATE_CONTACT,
'params' => [$ids],
'level' => 'Fatal',
'message' => 'Found matching contacts: ' . implode(',', $ids),
],
];
}
}
return civicrm_api3_create_success(TRUE);
return ['is_error' => 0];
}

0 comments on commit bb1f622

Please sign in to comment.