[REF] Move list of fields that have been upgraded
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 20 May 2022 03:39:43 +0000 (15:39 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 20 May 2022 03:40:26 +0000 (15:40 +1200)
CRM/Contact/Import/Parser/Contact.php
CRM/Import/Parser.php

index 67047e78128d5c9a6da48e4256b81a219f16811e..5e112df6bf0124a2c0e6084f6c7f800f9acf4500 100644 (file)
@@ -81,6 +81,20 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Import_Parser {
 
   protected $fieldMetadata = [];
 
+  /**
+   * Fields which are being handled by metadata formatting & validation functions.
+   *
+   * This is intended as a temporary parameter as we phase in metadata handling.
+   *
+   * The end result is that all fields will be & this will go but for now it is
+   * opt in.
+   *
+   * @var array
+   */
+  protected $metadataHandledFields = [
+    'gender_id',
+  ];
+
   /**
    * Relationship labels.
    *
index 5ccaf9858bf74137550bfc91e81cbea0de049e2b..43cd7dd9386aab88069b88b4a1f494d88d542e46 100644 (file)
@@ -53,6 +53,18 @@ abstract class CRM_Import_Parser {
    */
   protected $userJobID;
 
+  /**
+   * Fields which are being handled by metadata formatting & validation functions.
+   *
+   * This is intended as a temporary parameter as we phase in metadata handling.
+   *
+   * The end result is that all fields will be & this will go but for now it is
+   * opt in.
+   *
+   * @var array
+   */
+  protected $metadataHandledFields = [];
+
   /**
    * @return int|null
    */
@@ -1186,8 +1198,8 @@ abstract class CRM_Import_Parser {
    * @throws \API_Exception
    */
   protected function getTransformedFieldValue(string $fieldName, $importedValue) {
-    // For now only do gender_id as we need to work through removing duplicate handling
-    if ($fieldName !== 'gender_id' || empty($importedValue)) {
+    // For now only do gender_id etc as we need to work through removing duplicate handling
+    if (empty($importedValue) || !in_array($fieldName, $this->metadataHandledFields, TRUE)) {
       return $importedValue;
     }
     return $this->getFieldOptions($fieldName)[$importedValue] ?? 'invalid_import_value';