Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Import] Unpack the weird wild error return #23474

Merged
merged 1 commit into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
}
5 changes: 1 addition & 4 deletions tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,8 @@ public function tearDown(): void {

/**
* Test Import.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testImport() {
public function testImport(): void {
$this->individualCreate();
$contact2Params = [
'first_name' => 'Anthonita',
Expand Down