diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index eed4f89..77ce647 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -616,9 +616,12 @@ protected function castValue($key, $value) { } } else { - // Any non-scalar value must be an array. + // Throw exception on any non-scalar or non-array value. if (!is_array($value)) { - $value = (array) $value; + throw new UnsupportedConfigDataTypeException(format_string('Invalid data type for config element @name:@key', array( + '@name' => $this->getName(), + '@key' => $key, + ))); } // Recurse into any nested keys. foreach ($value as $nested_value_key => $nested_value) { diff --git a/core/lib/Drupal/Core/Config/UnsupportedConfigDataTypeException.php b/core/lib/Drupal/Core/Config/UnsupportedConfigDataTypeException.php new file mode 100644 index 0000000..ac63c26 --- /dev/null +++ b/core/lib/Drupal/Core/Config/UnsupportedConfigDataTypeException.php @@ -0,0 +1,14 @@ +set('stream', fopen(__FILE__, 'r'))->save(); $this->fail('No Exception thrown upon saving invalid data type.'); } - catch (\Exception $e) { + catch (UnsupportedConfigDataTypeException $e) { $this->pass(format_string('%class thrown upon saving invalid data type.', array( '%class' => get_class($e), ))); diff --git a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml index e421963..6f4ccbe 100644 --- a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml +++ b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml @@ -180,8 +180,11 @@ config_test.types: label: 'Configuration type' mapping: array: - type: mapping + type: sequence label: 'Array' + sequence: + - type: string + label: 'Item' boolean: type: boolean label: 'Boolean'