Skip to content

Commit

Permalink
Merge pull request #23470 from eileenmcnaughton/import_dataform
Browse files Browse the repository at this point in the history
[REF] [Import] Stop calling Parser in MapField mode (contact import)
  • Loading branch information
monishdeb authored May 18, 2022
2 parents 78dcfbb + f5d163d commit 4dc354e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
16 changes: 0 additions & 16 deletions CRM/Contact/Import/Form/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ public function postProcess() {
$this->flushDataSource();
$this->updateUserJobMetadata('submitted_values', $this->getSubmittedValues());
}
// Setup the params array
$this->_params = $this->controller->exportValues($this->_name);

// @todo - this params are being set here because they were / possibly still
// are in some places being accessed by forms later in the flow
Expand All @@ -194,9 +192,6 @@ public function postProcess() {
// Once the mentioned forms no longer call $this->get() all this 'setting'
// is obsolete.
$storeParams = [
'onDuplicate' => $this->getSubmittedValue('onDuplicate'),
'dedupe' => $this->getSubmittedValue('dedupe_rule_id'),
'contactType' => $this->getSubmittedValue('contactType'),
'dateFormats' => $this->getSubmittedValue('dateFormats'),
'savedMapping' => $this->getSubmittedValue('savedMapping'),
];
Expand All @@ -207,17 +202,6 @@ public function postProcess() {
CRM_Core_Session::singleton()->set('dateTypes', $storeParams['dateFormats']);

$this->instantiateDataSource();

$mapper = [];

$parser = new CRM_Contact_Import_Parser_Contact($mapper);
$parser->setMaxLinesToProcess(100);
$parser->setUserJobID($this->getUserJobID());
$parser->run(
[],
CRM_Import_Parser::MODE_MAPFIELD
);

}

/**
Expand Down
17 changes: 1 addition & 16 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2235,29 +2235,14 @@ public function run(
if ($mode == self::MODE_IMPORT) {
$dataSource->setStatuses(['new']);
}
if ($this->_maxLinesToProcess > 0) {
// Note this would only be the case in MapForm mode, where it is set to 100
// rows. In fact mapField really only needs 2 rows - the reason for
// 100 seems to be that the other import classes are processing a
// csv file, and there was a concern that some rows might have more
// columns than others - hence checking 100 rows perhaps seemed like
// a good precaution presumably when determining the activeFieldsCount
// which is the number of columns a row might have.
// However, the mapField class may no longer use activeFieldsCount for contact
// to be continued....
$dataSource->setLimit($this->_maxLinesToProcess);
}

while ($row = $dataSource->getRow()) {
$values = array_values($row);
$this->_rowCount++;

$this->_totalCount++;

if ($mode == self::MODE_MAPFIELD) {
$returnCode = CRM_Import_Parser::VALID;
}
elseif ($mode == self::MODE_PREVIEW) {
if ($mode == self::MODE_PREVIEW) {
$returnCode = $this->preview($values);
}
elseif ($mode == self::MODE_SUMMARY) {
Expand Down

0 comments on commit 4dc354e

Please sign in to comment.