From: Eileen McNaughton Date: Sun, 2 Apr 2023 04:36:32 +0000 (+1200) Subject: Fix enotice when using Civi-import X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=28ef420852e981f6bed7b2a4060f65e5f35d26ee;p=civicrm-core.git Fix enotice when using Civi-import --- diff --git a/CRM/Import/Form/MapField.php b/CRM/Import/Form/MapField.php index 7c7b431d41..f3eea0aff8 100644 --- a/CRM/Import/Form/MapField.php +++ b/CRM/Import/Form/MapField.php @@ -224,8 +224,19 @@ abstract class CRM_Import_Form_MapField extends CRM_Import_Forms { * @throws \CRM_Core_Exception */ protected function saveMappingField(int $mappingID, int $columnNumber, bool $isUpdate = FALSE): void { - $fieldMapping = (array) $this->getSubmittedValue('mapper')[$columnNumber]; - $mappedField = $this->getMappedField($fieldMapping, $mappingID, $columnNumber); + if (!empty($this->userJob['metadata']['import_mappings'])) { + // In this case Civi-Import has already saved the mapping to civicrm_user_job.metadata + // and the code here is just keeping civicrm_mapping_field in sync. + // Eventually we hope to phase out the use of the civicrm_mapping data & + // just use UserJob and Import Templates (UserJob records with 'is_template' = 1 + $mappedFieldData = $this->userJob['metadata']['import_mappings'][$columnNumber]; + $mappedField = array_intersect_key(array_fill_keys(['name', 'column_number', 'entity_data'], TRUE), $mappedFieldData); + $mappedField['mapping_id'] = $mappingID; + } + else { + $fieldMapping = (array) $this->getSubmittedValue('mapper')[$columnNumber]; + $mappedField = $this->getMappedField($fieldMapping, $mappingID, $columnNumber); + } if (empty($mappedField['name'])) { $mappedField['name'] = 'do_not_import'; }