From cebb24926ec993758a1ae8e9b74468fe88cd1a57 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 24 May 2022 12:58:09 +1200 Subject: [PATCH] Improve comparison for options --- CRM/Import/Parser.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 415644dba5..8d9742b7ce 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -1233,7 +1233,7 @@ abstract class CRM_Import_Parser { $value = CRM_Utils_Date::formatDate($importedValue, $this->getSubmittedValue('dateFormats')); return ($value) ?: 'invalid_import_value'; } - return $this->getFieldOptions($fieldName)[$importedValue] ?? 'invalid_import_value'; + return $this->getFieldOptions($fieldName)[is_numeric($importedValue) ? $importedValue : mb_strtolower($importedValue)] ?? 'invalid_import_value'; } /** @@ -1274,16 +1274,12 @@ abstract class CRM_Import_Parser { 'select' => ['options'], ])->first()['options']; // We create an array of the possible variants - notably including - // name AND label as either might be used, and capitalisation variants. + // name AND label as either might be used. We also lower case before checking $values = []; foreach ($options as $option) { $values[$option['id']] = $option['id']; - $values[$option['label']] = $option['id']; - $values[$option['name']] = $option['id']; - $values[strtoupper($option['name'])] = $option['id']; - $values[strtolower($option['name'])] = $option['id']; - $values[strtoupper($option['label'])] = $option['id']; - $values[strtolower($option['label'])] = $option['id']; + $values[mb_strtolower($option['name'])] = $option['id']; + $values[mb_strtolower($option['label'])] = $option['id']; } $this->importableFieldsMetadata[$fieldName]['options'] = $values; } -- 2.25.1