diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index a72ddf6..eb21ed8 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -180,19 +180,21 @@ protected function castValue($key, $value) { if ($element && $element instanceof Property) { return $value; } - if ((is_scalar($value) || $value === NULL) && ($element && $element instanceof PrimitiveInterface)) { - // Special handling for integers and floats since the configuration - // system is primarily concerned with saving values from the Form API - // we have to special case the meaning of an empty string for numeric - // types. In PHP this would be casted to a 0 but for the purposes of - // configuration we need to treat this as a NULL. - $empty_value = $value === '' && ($element instanceof IntegerInterface || $element instanceof FloatInterface); - - if ($value === NULL || $empty_value) { - $value = NULL; - } - else { - $value = $element->getCastedValue(); + if ((is_scalar($value) || $value === NULL)) { + if ($element && $element instanceof PrimitiveInterface) { + // Special handling for integers and floats since the configuration + // system is primarily concerned with saving values from the Form API + // we have to special case the meaning of an empty string for numeric + // types. In PHP this would be casted to a 0 but for the purposes of + // configuration we need to treat this as a NULL. + $empty_value = $value === '' && ($element instanceof IntegerInterface || $element instanceof FloatInterface); + + if ($value === NULL || $empty_value) { + $value = NULL; + } + else { + $value = $element->getCastedValue(); + } } } else {