diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index b50cb47e0956..a1b98e4b71cc 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -174,7 +174,7 @@ public function summary(&$values): int { * @throws \CRM_Core_Exception * @throws \API_Exception */ - public function import(&$values) { + public function import($values) { $rowNumber = (int) $values[array_key_last($values)]; $this->_unparsedStreetAddressContacts = []; diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 9cec7a68a891..30b8c8ae5ff4 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -1718,17 +1718,7 @@ public static function runImport($taskContext, $userJobID, $limit) { while ($row = $dataSource->getRow()) { $values = array_values($row); - - try { - $parser->import($values); - } - catch (CiviCRM_API3_Exception $e) { - // When we catch errors here we are not adding to the errors array - mostly - // because that will become obsolete once https://github.com/civicrm/civicrm-core/pull/23292 - // is merged and this will replace it as the main way to handle errors (ie. update the table - // and move on). - $parser->setImportStatus((int) $values[count($values) - 1], 'ERROR', $e->getMessage()); - } + $parser->import($values); } $parser->doPostImportActions(); return TRUE; diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index b665d9986bb1..0c191941767a 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -88,7 +88,7 @@ public function testImportParserWithEmployeeOfRelationship(): void { $parser->setUserJobID($userJobID); $parser->init(); - $this->assertEquals(CRM_Import_Parser::VALID, $parser->import(CRM_Import_Parser::DUPLICATE_UPDATE, $values), 'Return code from parser import was not as expected'); + $this->assertEquals(CRM_Import_Parser::VALID, $parser->import($values), 'Return code from parser import was not as expected'); $this->callAPISuccessGetSingle('Contact', [ 'first_name' => 'Alok', 'last_name' => 'Patel', @@ -1623,7 +1623,7 @@ protected function runImport(array $originalValues, $onDuplicateAction, $expecte $parser->setUserJobID($userJobID); $parser->_dedupeRuleGroupID = $ruleGroupId; $parser->init(); - $result = $parser->import($onDuplicateAction, $values); + $result = $parser->import($values); $dataSource = new CRM_Import_DataSource_CSV($userJobID); if ($result === FALSE && $expectedResult !== FALSE) { // Import is moving away from returning a status - this is a better way to check @@ -1906,7 +1906,7 @@ public function testImportParserDoesNotMatchPrimaryToRelated(): void { $parser = new CRM_Contact_Import_Parser_Contact(); $parser->setUserJobID($userJobID); $parser->init(); - $parser->import(CRM_Import_Parser::DUPLICATE_UPDATE, $values); + $parser->import($values); $this->callAPISuccessGetSingle('Contact', [ 'first_name' => 'Bob', 'last_name' => 'Dobbs', @@ -2137,17 +2137,17 @@ public function testImportParserWithExternalIdForRelationship(bool $isOrganizati ['5_a_b', 'external_identifier'], ['5_a_b', 'organization_name'], ]; - $fields = array_keys($contactImportValues); + $values = array_values($contactImportValues); $userJobID = $this->getUserJobID([ 'mapper' => $mapper, ]); - $parser = new CRM_Contact_Import_Parser_Contact($fields); + $parser = new CRM_Contact_Import_Parser_Contact(); $parser->setUserJobID($userJobID); $parser->init(); - $parser->import(CRM_Import_Parser::DUPLICATE_UPDATE, $values); + $parser->import($values); $this->callAPISuccessGetCount('Contact', ['organization_name' => 'Big shop'], $isOrganizationProvided ? 2 : 0); }