diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 02afbd1..8263fd1 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -208,13 +208,6 @@ public function isNew() { * would return array('bar' => 'baz'). * If no key is specified, then the entire data array is returned. * - * The configuration system does not retain data types. Every saved value is - * casted to a string. In most cases this is not an issue; however, it can - * cause issues with Booleans, which are casted to "1" (TRUE) or "0" (FALSE). - * In particular, code relying on === or !== will no longer function properly. - * - * @see http://php.net/manual/language.operators.comparison.php - * * @return mixed * The data that was requested. */ @@ -338,8 +331,6 @@ public function set($key, $value) { if (!$this->isLoaded) { $this->load(); } - // Type-cast value into a string. - $value = $this->castValue($value); // The dot/period is a reserved character; it may appear between keys, but // not within keys. @@ -355,46 +346,6 @@ public function set($key, $value) { } /** - * Casts a saved value to a string. - * - * The configuration system only saves strings or arrays. Any scalar - * non-string value is cast to a string. The one exception is boolean FALSE - * which would normally become '' when cast to a string, but is manually - * cast to '0' here for convenience and consistency. - * - * Any non-scalar value that is not an array (aka objects) gets cast - * to an array. - * - * @param mixed $value - * A value being saved into the configuration system. - * - * @return string - * The value cast to a string or array. - */ - public function castValue($value) { - if (is_scalar($value) || $value === NULL) { - // Handle special case of FALSE, which should be '0' instead of ''. - if ($value === FALSE) { - $value = '0'; - } - else { - $value = (string) $value; - } - } - else { - // Any non-scalar value must be an array. - if (!is_array($value)) { - $value = (array) $value; - } - // Recurse into any nested keys. - foreach ($value as $key => $nested_value) { - $value[$key] = $this->castValue($nested_value); - } - } - return $value; - } - - /** * Unsets value in this config object. * * @param string $key diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index 6e428b3..24a6511 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -153,6 +153,7 @@ protected function getDumper() { // 2 spaces for consistency with Drupal coding standards. $this->dumper->setIndentation(2); } + return $this->dumper; } @@ -175,8 +176,9 @@ 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. - return $this->getDumper()->dump($data, PHP_INT_MAX); + // 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/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 1e72237..fb7997b 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -95,18 +95,18 @@ protected function createTests() { // Ensure that default values are filled in. $expected_properties = array( 'id' => 'stark.test_block', - 'weight' => '', - 'status' => '1', + 'weight' => NULL, + 'status' => TRUE, 'langcode' => language_default()->id, - 'region' => '-1', + 'region' => -1, 'plugin' => 'test_html_id', 'settings' => array( - 'cache' => '1', + 'cache' => 1, 'label' => '', 'module' => 'block_test', 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, ), - 'visibility' => '', + 'visibility' => NULL, ); $this->assertIdentical($actual_properties, $expected_properties, 'The block properties are exported correctly.'); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php index d2e42f9..5d4a6cc 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php @@ -163,10 +163,10 @@ function testAdmin() { $this->drupalGet('admin/config/content/formats/manage/filtered_html'); $ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]'); $this->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is checked.'); - $expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = '1'; + $expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = 1; $editor = entity_load('editor', 'filtered_html'); $this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.'); - $this->assertIdentical($expected_settings, $editor->settings, 'The Editor config entity has the correct settings.'); + $this->assertIdentical($expected_settings, $editor->settings); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php index a5039e6..8efdf22 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php @@ -41,13 +41,13 @@ function setUp() { $filter_format = $filter_format_storage_controller->create(array( 'format' => 'basic_html', 'name' => 'Basic HTML', - 'status' => '1', + 'status' => TRUE, 'roles' => array('authenticated'), ), 'filter_format'); $filter_format->setFilterConfig('filter_html', array( 'module' => 'filter', - 'status' => '1', + 'status' => TRUE, 'settings' => array( 'allowed_html' => '