From 8a14f0f34a34aa4bee29c3d22015bec5a3c5b41e Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 21 Jul 2016 16:40:14 +1200 Subject: [PATCH] CRM-19074 if someone has deliberately chosen to overwrite with 'null', respect it. --- CRM/Contact/BAO/Contact.php | 4 ---- CRM/Dedupe/Merger.php | 46 +++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 4711af7451..4b222079f5 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2050,12 +2050,8 @@ ORDER BY civicrm_email.is_primary DESC"; $primaryPhoneLoc = NULL; $session = CRM_Core_Session::singleton(); foreach ($params as $key => $value) { - $locTypeId = $typeId = NULL; list($fieldName, $locTypeId, $typeId) = CRM_Utils_System::explode('-', $key, 3); - //store original location type id - $actualLocTypeId = $locTypeId; - if ($locTypeId == 'Primary') { if ($contactID) { if (in_array($fieldName, $blocks)) { diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index c12653c30c..ed55c653fc 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -1597,30 +1597,36 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]); if (is_array($existingValue) && !empty($existingValue)) { $mergeValue = $submmtedCustomValue = array(); - if ($value) { - $submmtedCustomValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + if ($value == 'null') { + // CRM-19074 if someone has deliberately chosen to overwrite with 'null', respect it. + $submitted[$key] = $value; } + else { + if ($value) { + $submmtedCustomValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + } - //hack to remove null and duplicate values from array. - foreach (array_merge($submmtedCustomValue, $existingValue) as $k => $v) { - if ($v != '' && !in_array($v, $mergeValue)) { - $mergeValue[] = $v; + //hack to remove null and duplicate values from array. + foreach (array_merge($submmtedCustomValue, $existingValue) as $k => $v) { + if ($v != '' && !in_array($v, $mergeValue)) { + $mergeValue[] = $v; + } } - } - //keep state and country as array format. - //for checkbox and m-select format w/ VALUE_SEPARATOR - if (in_array($htmlType, array( - 'CheckBox', - 'Multi-Select', - 'AdvMulti-Select', - ))) { - $submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, - $mergeValue - ) . CRM_Core_DAO::VALUE_SEPARATOR; - } - else { - $submitted[$key] = $mergeValue; + //keep state and country as array format. + //for checkbox and m-select format w/ VALUE_SEPARATOR + if (in_array($htmlType, array( + 'CheckBox', + 'Multi-Select', + 'AdvMulti-Select', + ))) { + $submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, + $mergeValue + ) . CRM_Core_DAO::VALUE_SEPARATOR; + } + else { + $submitted[$key] = $mergeValue; + } } } } -- 2.25.1