+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
+ | Copyright CiviCRM LLC (c) 2004-2020 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC (c) 2004-2020
*/
abstract class CRM_Import_Parser {
/**
/**
* Parse a field which could be represented by a label or name value rather than the DB value.
*
- * We will try to match name first but if not available then see if we have a label that can be converted to a name.
+ * We will try to match name first or (per https://lab.civicrm.org/dev/core/issues/1285 if we have an id.
+ *
+ * but if not available then see if we have a label that can be converted to a name.
*
* @param string|int|null $submittedValue
* @param array $fieldSpec
$bao = $fieldSpec['bao'];
// For historical reasons use validate as context - ie disabled name matches ARE permitted.
$nameOptions = $bao::buildOptions($fieldSpec['name'], 'validate');
- if (!isset($nameOptions[$submittedValue])) {
- $labelOptions = array_flip($bao::buildOptions($fieldSpec['name'], 'match'));
- if (isset($labelOptions[$submittedValue])) {
- return array_search($labelOptions[$submittedValue], $nameOptions, TRUE);
- }
+ if (isset($nameOptions[$submittedValue])) {
+ return $submittedValue;
+ }
+ if (in_array($submittedValue, $nameOptions)) {
+ return array_search($submittedValue, $nameOptions, TRUE);
+ }
+
+ $labelOptions = array_flip($bao::buildOptions($fieldSpec['name'], 'match'));
+ if (isset($labelOptions[$submittedValue])) {
+ return array_search($labelOptions[$submittedValue], $nameOptions, TRUE);
}
return '';
}