From: Eileen McNaughton Date: Tue, 9 Aug 2022 01:21:34 +0000 (+1200) Subject: Fold call to deprecated function back into calling function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=48d3de883388861320982a4a03ac117464bfc467;p=civicrm-core.git Fold call to deprecated function back into calling function --- diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index f50cff2fd1..a32fd16172 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -901,8 +901,46 @@ abstract class CRM_Import_Parser implements UserJobInterface { } $contactFormatted['contact_type'] = $contactType; + $params = &$contactFormatted; + $id = $params['id'] ?? NULL; + $externalId = $params['external_identifier'] ?? NULL; + if ($id || $externalId) { + $contact = new CRM_Contact_DAO_Contact(); + + $contact->id = $id; + $contact->external_identifier = $externalId; + + if ($contact->find(TRUE)) { + if ($params['contact_type'] != $contact->contact_type) { + return ['is_error' => 1, 'error_message' => 'Mismatched contact IDs OR Mismatched contact Types']; + } + 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'); - return _civicrm_api3_deprecated_duplicate_formatted_contact($contactFormatted); + if (!empty($ids)) { + return [ + 'is_error' => 1, + 'error_message' => [ + 'code' => CRM_Core_Error::DUPLICATE_CONTACT, + 'params' => $ids, + 'level' => 'Fatal', + 'message' => 'Found matching contacts: ' . implode(',', $ids), + ], + ]; + } + } + return ['is_error' => 0]; } /**