From 8fbfda98703327933577a429c654a5c31f7919d2 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 31 May 2022 10:21:11 +1200 Subject: [PATCH] Remove more checks that can be is_array --- CRM/Contact/Import/Parser/Contact.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 0b62f0618a..155578ad7d 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -331,7 +331,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $this->_retCode = CRM_Import_Parser::VALID; } } - elseif (CRM_Core_Error::isAPIError($newContact, CRM_Core_Error::DUPLICATE_CONTACT)) { + elseif (is_array($newContact)) { // if duplicate, no need of further processing if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP) { $errorMessage = "Skipping duplicate record"; @@ -372,7 +372,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { } $primaryContactId = NULL; - if (CRM_Core_Error::isAPIError($newContact, CRM_Core_ERROR::DUPLICATE_CONTACT)) { + if (is_array($newContact)) { if ($dupeCount == 1 && CRM_Utils_Rule::integer($contactID)) { $primaryContactId = $contactID; } @@ -381,7 +381,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $primaryContactId = $newContact->id; } - if ((CRM_Core_Error::isAPIError($newContact, CRM_Core_ERROR::DUPLICATE_CONTACT) || is_a($newContact, 'CRM_Contact_BAO_Contact')) && $primaryContactId) { + if ((is_array($newContact) || is_a($newContact, 'CRM_Contact_BAO_Contact')) && $primaryContactId) { //relationship contact insert foreach ($this->getRelatedContactsParams($params) as $key => $field) { @@ -420,17 +420,9 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { // To update/fill contact, get the matching contact Ids if duplicate contact found // otherwise get contact Id from object of related contact if (is_array($relatedNewContact)) { - if (CRM_Core_Error::isAPIError($relatedNewContact, CRM_Core_ERROR::DUPLICATE_CONTACT)) { - $matchedIDs = $relatedNewContact['error_message']['params'][0]; - if (!is_array($matchedIDs)) { - $matchedIDs = explode(',', $matchedIDs); - } - } - else { - $errorMessage = $relatedNewContact['error_message']; - array_unshift($values, $errorMessage); - $this->setImportStatus((int) $values[count($values) - 1], 'ERROR', $errorMessage); - return CRM_Import_Parser::ERROR; + $matchedIDs = $relatedNewContact['error_message']['params'][0]; + if (!is_array($matchedIDs)) { + $matchedIDs = explode(',', $matchedIDs); } } else { @@ -454,11 +446,11 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { return CRM_Import_Parser::NO_MATCH; } else { - $updatedContact = $this->createContact($formatting, $contactFields, $onDuplicate, $matchedIDs[0]); + $this->createContact($formatting, $contactFields, $onDuplicate, $matchedIDs[0]); } } static $relativeContact = []; - if (CRM_Core_Error::isAPIError($relatedNewContact, CRM_Core_ERROR::DUPLICATE_CONTACT)) { + if (is_array($relatedNewContact)) { if (count($matchedIDs) >= 1) { $relContactId = $matchedIDs[0]; //add relative contact to count during update & fill mode. @@ -480,7 +472,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $this->_newRelatedContacts[] = $relativeContact[] = $relContactId; } - if (CRM_Core_Error::isAPIError($relatedNewContact, CRM_Core_ERROR::DUPLICATE_CONTACT) || ($relatedNewContact instanceof CRM_Contact_BAO_Contact)) { + if (is_array($relatedNewContact) || ($relatedNewContact instanceof CRM_Contact_BAO_Contact)) { //fix for CRM-1993.Checks for duplicate related contacts if (count($matchedIDs) >= 1) { //if more than one duplicate contact -- 2.25.1