diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index 5f5d007..a32087a 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -218,15 +218,13 @@ protected function castValue($key, $value) { $value[$nested_value_key] = $this->castValue($lookup_key, $nested_value); } - if ($element instanceof Mapping) { + // Only sort maps when we have more than 1 element to sort. + if ($element instanceof Mapping && count($value) > 1) { $mapping = $element->getDataDefinition()['mapping']; - // It is possible the schema is incomplete and the mapping not defined. - if (is_array($mapping)) { - // Only sort the keys in $value. - $mapping = array_intersect_key($mapping, $value); - // Sort the array in $value using the mapping definition. - $value = array_replace($mapping, $value); - } + // Only sort the keys in $value. + $mapping = array_intersect_key($mapping, $value); + // Sort the array in $value using the mapping definition. + $value = array_replace($mapping, $value); } } return $value;