diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index 24bc4d2..5c6e8b3 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -136,8 +136,15 @@ protected function getSchemaWrapper() { /** * Validate the values are allowed data types. * - * @throws UnsupportedDataTypeConfigException - * If there is any invalid value. + * @param string $key + * A string that maps to a key within the configuration data. + * @param string $value + * Value to associate with the key. + * + * @return null + * + * @throws \Drupal\Core\Config\UnsupportedDataTypeConfigException + * If the value is unsupported in configuration. */ protected function validateValue($key, $value) { // Minimal validation. Should not try to serialize resources or non-arrays. @@ -166,12 +173,15 @@ protected function validateValue($key, $value) { * The value cast to the type indicated in the schema. * * @throws \Drupal\Core\Config\UnsupportedDataTypeConfigException - * Exception on unsupported/undefined data type deducted. + * If the value is unsupported in configuration. */ protected function castValue($key, $value) { $element = $this->getSchemaWrapper()->get($key); // Do not cast value if it is unknown or defined to be ignored. if ($element && ($element instanceof Undefined || $element instanceof Ignore)) { + // Do validate the value (may throw UnsupportedDataTypeConfigException) + // to ensure unsupported types are not supported in this case either. + $this->validateValue($key, $value); return $value; } if (is_scalar($value) || $value === NULL) {