Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Won't Fix
-
Affects Version/s: 3.3.5
-
Fix Version/s: Unscheduled
-
Component/s: Core CiviCRM
-
Labels:None
Description
I have two dedupe rules, used one after another for different contact import operations using the same CSV file (One to bring in totally new contacts, one to intentionally make duplicates in case of name/address changes).
In one of the rules, first_name is not used as one of the contact matching fileds, but in the other it is. When I use the first rule and load the mapping, all is well, but when I switch to the second rule and load the mapping, first_name isn't mapped to the correct field, and has to be chosen manually.
This is because the civicrm_mapping_fields table stores 'First Name (match to contact)' the in the name field and then uses this to find the default from the mapper on line 576 of /CRM/Form/Import/MapField.php:
$mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);
Where $this->_mapperFields has an array item like this:
[first_name] => 'First Name'
I've put in a rough and ready fix like this:
$mappingHeader = array_keys($this->_mapperFields, $mappingName[$i]);
if (!$mappingHeader) {
// add or remove the '(match to contacts)' bit and try again
if (strpos($mappingName[$i], '(match to contact)') !== false)
else
{ $nameToFind = $mappingName[$i].' (match to contact)'; } $mappingHeader = array_keys($this->_mapperFields, $nameToFind);
}
But I imagine it would be best to keep the '(match to contact)' bit out of the mapper_fields table entirely.