Skip to content

Commit

Permalink
Fix state & country handling in contact import
Browse files Browse the repository at this point in the history
Fixes a regression where case has become sensitive. Also fixes custom state & country fields
to be case insensitive
  • Loading branch information
eileenmcnaughton committed May 31, 2022
1 parent dc73fa0 commit 0674150
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 245 deletions.
40 changes: 0 additions & 40 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -781,46 +781,6 @@ protected static function contactTrash($contact): bool {
*
*/
public static function resolveDefaults(&$defaults, $reverse = FALSE) {

$blocks = ['address'];
foreach ($blocks as $name) {
if (!array_key_exists($name, $defaults) || !is_array($defaults[$name])) {
continue;
}
foreach ($defaults[$name] as $count => & $values) {

//get location type id.
CRM_Utils_Array::lookupValue($values, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), $reverse);

if ($name == 'address') {
// FIXME: lookupValue doesn't work for vcard_name
if (!empty($values['location_type_id'])) {
$vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'vcard_name']);
$values['vcard_name'] = $vcardNames[$values['location_type_id']];
}

$stateProvinceID = self::resolveStateProvinceID($values, $values['country_id'] ?? NULL);
if ($stateProvinceID) {
$values['state_province_id'] = $stateProvinceID;
}

if (!empty($values['state_province_id'])) {
$countyList = CRM_Core_PseudoConstant::countyForState($values['state_province_id']);
}
else {
$countyList = CRM_Core_PseudoConstant::county();
}
CRM_Utils_Array::lookupValue($values,
'county',
$countyList,
$reverse
);
}

// Kill the reference.
unset($values);
}
}
}

/**
Expand Down
Loading

0 comments on commit 0674150

Please sign in to comment.