Skip to content

Commit

Permalink
Merge pull request #23343 from eileenmcnaughton/import_parser_job
Browse files Browse the repository at this point in the history
[REF] [Import] Stop passing submittedValues as parameters
  • Loading branch information
seamuslee001 authored May 5, 2022
2 parents aa3ca5c + dba9288 commit 4143c82
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
23 changes: 7 additions & 16 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,16 @@ public function getAllFields() {
* @param array $values
* The array of values belonging to this line.
*
* @param bool $doGeocodeAddress
*
* @return bool
* the result of this processing
*
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
* @throws \API_Exception
*/
public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) {
public function import($onDuplicate, &$values) {
$this->_unparsedStreetAddressContacts = [];
if (!$doGeocodeAddress) {
if (!$this->getSubmittedValue('doGeocodeAddress')) {
// CRM-5854, reset the geocode method to null to prevent geocoding
CRM_Utils_GeocodeProvider::disableForSession();
}
Expand Down Expand Up @@ -2446,12 +2444,9 @@ public function deprecated_contact_check_params(
* @param int $onDuplicate
* @param int $statusID
* @param int $totalRowCount
* @param bool $doGeocodeAddress
* @param int $timeout
* @param string $contactSubType
* @param int $dedupeRuleGroupID
*
* @return mixed
* @throws \API_Exception
*/
public function run(
$tableName,
Expand All @@ -2462,16 +2457,12 @@ public function run(
$statusFieldName = '_status',
$onDuplicate = self::DUPLICATE_SKIP,
$statusID = NULL,
$totalRowCount = NULL,
$doGeocodeAddress = FALSE,
$timeout = CRM_Contact_Import_Parser_Contact::DEFAULT_TIMEOUT,
$contactSubType = NULL,
$dedupeRuleGroupID = NULL
$totalRowCount = NULL
) {

// TODO: Make the timeout actually work
$this->_onDuplicate = $onDuplicate;
$this->_dedupeRuleGroupID = $dedupeRuleGroupID;
$this->_onDuplicate = $onDuplicate = $this->getSubmittedValue('onDuplicate');
$this->_dedupeRuleGroupID = $this->getSubmittedValue('dedupe_rule_id');
// Since $this->_contactType is still being called directly do a get call
// here to make sure it is instantiated.
$this->getContactType();
Expand Down Expand Up @@ -2544,7 +2535,7 @@ public function run(
}
elseif ($mode == self::MODE_IMPORT) {
try {
$returnCode = $this->import($onDuplicate, $values, $doGeocodeAddress);
$returnCode = $this->import($onDuplicate, $values);
}
catch (CiviCRM_API3_Exception $e) {
// When we catch errors here we are not adding to the errors array - mostly
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Contact/Import/Form/MapFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function getMapFieldFormObject(array $submittedValues = []): CRM_Contact_
'contactSubType' => '',
'dataSource' => 'CRM_Import_DataSource_SQL',
'sqlQuery' => 'SELECT * FROM civicrm_tmp_d_import_job_xxx',
'dedupe_rule_id' => '',
'onDuplicate' => CRM_Import_Parser::DUPLICATE_UPDATE,
], $submittedValues);
$userJobID = UserJob::create()->setValues([
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,7 @@ protected function getUserJobID($submittedValues = []) {
'submitted_values' => array_merge([
'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL,
'contactSubType' => '',
'doGeocodeAddress' => 0,
], $submittedValues),
],
'status_id:name' => 'draft',
Expand Down

0 comments on commit 4143c82

Please sign in to comment.