diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index ded8052..a08af4b 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -163,7 +163,8 @@ protected function getParser() { */ public function encode($data) { // The level where you switch to inline YAML is set to PHP_INT_MAX to ensure - // this does not occur. + // this does not occur. Also set the exceptionOnInvalidType parameter to + // TRUE, so exceptions are thrown for an invalid data type. return $this->getDumper()->dump($data, PHP_INT_MAX, 0, TRUE); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php index d0fb753..fec4aee 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php @@ -204,6 +204,7 @@ function testDataTypes() { 'int' => 99, 'octal' => 0775, 'string' => 'string', + 'string_int' => '1', ); $this->assertIdentical($config->get(), $data); @@ -219,21 +220,14 @@ function testDataTypes() { $config->setData($data)->save(); $this->assertIdentical($config->get(), $data); - $data = array( - // Yaml cannot dump resources. - 'stream' => fopen(__FILE__, 'r'), - ); - foreach ($data as $key => $value) { - $config->set($key, $value); - try { - $config->save(); - $this->fail('No Exception thrown upon saving invalid data type.'); - } - catch (\Exception $e) { - $this->pass(format_string('%class thrown upon saving invalid data type.', array( - '%class' => get_class($e), - ))); - } + try { + $config->set('stream', fopen(__FILE__, 'r'))->save(); + $this->fail('No Exception thrown upon saving invalid data type.'); + } + catch (\Exception $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/config_test.types.yml b/core/modules/config/tests/config_test/config/config_test.types.yml index 36dc08d..664325f 100644 --- a/core/modules/config/tests/config_test/config/config_test.types.yml +++ b/core/modules/config/tests/config_test/config/config_test.types.yml @@ -5,4 +5,5 @@ float: 3.14159 hex: 0xC int: 99 octal: 0775 -string: string \ No newline at end of file +string: string +string_int: '1' \ No newline at end of file