CRM-19664 - continue with import even if one row has extid match
authorJamie McClelland <jm@mayfirst.org>
Fri, 18 Nov 2016 19:42:25 +0000 (14:42 -0500)
committerJamie McClelland <jm@mayfirst.org>
Fri, 18 Nov 2016 19:42:25 +0000 (14:42 -0500)
problem.

CRM/Contact/Import/Parser/Contact.php

index 2cffc5dc911fcb7c7bff5c4a7b22f8628de1e777..4e3cb95ad5347978308e11c62901584e50d3858a 100644 (file)
@@ -539,7 +539,20 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
     // Get contact id to format common data in update/fill mode,
     // prioritising a dedupe rule check over an external_identifier check, but falling back on ext id.
     if ($this->_updateWithId && empty($params['id'])) {
-      $possibleMatches = $this->getPossibleContactMatches($params);
+      try {
+        $possibleMatches = $this->getPossibleContactMatches($params);
+      }
+      catch (CRM_Core_Exception $e) {
+       $errorMessage = $e->getMessage();
+       array_unshift($values, $errorMessage);
+
+        $importRecordParams = array(
+          $statusFieldName => 'ERROR',
+          "${statusFieldName}Msg" => $errorMessage
+         );
+         $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
+         return CRM_Import_Parser::ERROR;
+      }
       foreach ($possibleMatches as $possibleID) {
         $params['id'] = $formatted['id'] = $possibleID;
       }