Skip to content
Snippets Groups Projects
Commit 416d6fa9 authored by Eileen McNaughton's avatar Eileen McNaughton
Browse files

Fix import to retry invalid

parent 9eb41381
Branches
Tags
No related merge requests found
......@@ -2548,16 +2548,20 @@ abstract class CRM_Import_Parser implements UserJobInterface {
/**
* @param array|null $row
*
* @return bool
*/
public function validateRow(?array $row): void {
public function validateRow(?array $row): bool {
try {
$rowNumber = $row['_id'];
$values = array_values($row);
$this->validateValues($values);
$this->setImportStatus($rowNumber, 'VALID', '');
return TRUE;
}
catch (CRM_Core_Exception $e) {
$this->setImportStatus($rowNumber, 'ERROR', $e->getMessage());
return FALSE;
}
}
......
......@@ -25,10 +25,12 @@ class Import extends DAOGetAction {
public function _run(Result $result): void {
$userJobID = (int) str_replace('Import_', '', $this->_entityName);
$where = $this->where;
$this->addWhere('_status', 'IN', ['new', 'valid']);
$this->getImportRows($result);
$parser = $this->getParser($userJobID);
foreach ($result as $row) {
if (!in_array($row['_status'], ['new', 'valid'], TRUE) && !$parser->validateRow($row)) {
continue;
}
$parser->import(array_values($row));
}
$parser->doPostImportActions();
......
......@@ -66,6 +66,7 @@ trait ImportProcessTrait {
->indexBy('name'));
$importFields[] = '_id';
$importFields[] = '_entity_id';
$importFields[] = '_status';
$this->setSelect($importFields);
parent::_run($result);
foreach ($result as &$row) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment