Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] [Import] Stop calling Parser in MapField mode (contact import) #23470

Merged
merged 1 commit into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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