From d6e353391c4e9f9e65ffc50ebd02f52b73978036 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 6 May 2022 10:48:28 +1200 Subject: [PATCH] [REF] Import - make condition clearer The mapping of fields basically breaks down into 'has a relationship' - in which case fieldName is empy and does not have a relationship - in which case field name is not empy. This makes that explicit - specifically referring to relatedContactKey rather than relying on the person reading the code understanding that the presence of fieldName implies whether it is a relationship --- CRM/Contact/Import/Parser/Contact.php | 61 ++++++++++++++------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index bd2117ad8b..8e369a0e77 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -2637,44 +2637,45 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser { $importedValue = $this->_activeFields[$i]->_value; if (isset($importedValue)) { - if (isset($locationTypeID)) { - if (!isset($params[$fieldName])) { - $params[$fieldName] = []; - } + if (!$relatedContactKey) { + if (isset($locationTypeID)) { + if (!isset($params[$fieldName])) { + $params[$fieldName] = []; + } - $value = [ - $fieldName => $importedValue, - 'location_type_id' => $locationTypeID, - ]; + $value = [ + $fieldName => $importedValue, + 'location_type_id' => $locationTypeID, + ]; - if (isset($phoneTypeID)) { - $value['phone_type_id'] = $phoneTypeID; - } + if (isset($phoneTypeID)) { + $value['phone_type_id'] = $phoneTypeID; + } - // get IM service Provider type id - if (isset($imProviderID)) { - $value['provider_id'] = $imProviderID; - } + // get IM service Provider type id + if (isset($imProviderID)) { + $value['provider_id'] = $imProviderID; + } - $params[$fieldName][] = $value; - } - elseif (isset($websiteTypeID)) { - $value = [ - $fieldName => $importedValue, - 'website_type_id' => $websiteTypeID, - ]; + $params[$fieldName][] = $value; + } + elseif (isset($websiteTypeID)) { + $value = [ + $fieldName => $importedValue, + 'website_type_id' => $websiteTypeID, + ]; - $params[$fieldName][] = $value; - } + $params[$fieldName][] = $value; + } - if (!isset($params[$fieldName])) { - if (!isset($relatedContactKey)) { - $params[$fieldName] = $importedValue; + if (!isset($params[$fieldName])) { + if (!isset($relatedContactKey)) { + $params[$fieldName] = $importedValue; + } } - } - //minor fix for CRM-4062 - if (isset($relatedContactKey)) { + } + else { if (!isset($params[$relatedContactKey])) { $params[$relatedContactKey] = []; } -- 2.25.1