[REF] Stop returning unused variables
[civicrm-core.git] / CRM / Contact / Import / Parser / Contact.php
index 70da80437072187982e4246b97210f369b22ea8a..8399c5fb401d123037f758c9cc49ab5e2ecd3c5a 100644 (file)
@@ -621,6 +621,12 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
         ->setLoadOptions(TRUE)
         ->execute()->indexBy('name');
       foreach ($fields as $fieldName => $fieldSpec) {
+        if (isset($formatted[$fieldName]) && is_array($formatted[$fieldName])) {
+          // If we have an array at this stage, it's probably a multi-select
+          // field that has already been parsed properly into the value that
+          // should be inserted into the database.
+          continue;
+        }
         if (!empty($formatted[$fieldName])
           && empty($fieldSpec['options'][$formatted[$fieldName]])) {
           $formatted[$fieldName] = array_search($formatted[$fieldName], $fieldSpec['options'], TRUE) ?? $formatted[$fieldName];
@@ -887,7 +893,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
                 'contact' => $primaryContactId,
               ];
 
-              [$valid, $invalid, $duplicate, $saved, $relationshipIds] = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
+              [$valid, $duplicate] = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
 
               if ($valid || $duplicate) {
                 $relationIds['contactTarget'] = $relContactId;
@@ -997,7 +1003,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
     }
 
     // get array of subtypes - CRM-18708
-    if (in_array($csType, ['Individual', 'Organization', 'Household'])) {
+    if (in_array($csType, CRM_Contact_BAO_ContactType::basicTypes(TRUE), TRUE)) {
       $csType = self::getSubtypes($params['contact_type']);
     }
 
@@ -1068,7 +1074,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           }
 
           // check for values for custom fields for checkboxes and multiselect
-          if ($isSerialized) {
+          if ($isSerialized && $dataType != 'ContactReference') {
             $value = trim($value);
             $value = str_replace('|', ',', $value);
             $mulValues = explode(',', $value);
@@ -2109,9 +2115,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
       $requiredCheck = FALSE;
     }
     if ($requiredCheck) {
-      if (isset($params['id'])) {
-        $required = ['Individual', 'Household', 'Organization'];
-      }
       $required = [
         'Individual' => [
           ['first_name', 'last_name'],