diff -u b/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php --- b/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -205,7 +205,24 @@ * {@inheritdoc} */ public function save() { - $this->preSave(); + // Validate the configuration object name before saving. + static::validateName($this->name); + + // If there is a schema for this configuration object, cast all values to + // conform to the schema. + if ($this->typedConfigManager->hasConfigSchema($this->name)) { + // Ensure that the schema wrapper has the latest data. + $this->schemaWrapper = NULL; + foreach ($this->data as $key => $value) { + $this->data[$key] = $this->castValue($key, $value); + } + } + else { + foreach ($this->data as $key => $value) { + $this->validateValue($key, $value); + } + } + $this->storage->write($this->name, $this->data); $this->isNew = FALSE; $this->eventDispatcher->dispatch(ConfigEvents::SAVE, new ConfigCrudEvent($this)); reverted: --- b/core/lib/Drupal/Core/Config/InstallStorage.php +++ a/core/lib/Drupal/Core/Config/InstallStorage.php @@ -221,18 +221,4 @@ $this->folders = NULL; } - /** - * {@inheritdoc} - */ - public function getAllCollectionNames() { - $collections = array(); - $folders = array_unique(array_values($this->getAllFolders())); - foreach ($folders as $directory) { - $collections = array_merge($collections, $this->getAllCollectionNamesHelper($directory)); - } - $collections = array_unique($collections); - sort($collections); - return $collections; - } - } reverted: --- b/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ a/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -115,31 +115,6 @@ } /** - * Ensures validity of the configuration using schema if available. - * - * If the configuration is invalid in any way exceptions are thrown. - */ - protected function preSave() { - // Validate the configuration object name before saving. - static::validateName($this->name); - - // If there is a schema for this configuration object, cast all values to - // conform to the schema. - if ($this->typedConfigManager->hasConfigSchema($this->name)) { - // Ensure that the schema wrapper has the latest data. - $this->schemaWrapper = NULL; - foreach ($this->data as $key => $value) { - $this->data[$key] = $this->castValue($key, $value); - } - } - else { - foreach ($this->data as $key => $value) { - $this->validateValue($key, $value); - } - } - } - - /** * Gets the schema wrapper for the whole configuration object. * * The schema wrapper is dependent on the configuration name and the whole reverted: --- b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTestBase.php +++ a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTestBase.php @@ -9,7 +9,6 @@ use Drupal\Core\Config\Schema\ArrayElement; use Drupal\Core\Config\Schema\Property; -use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\TypedData\Type\BooleanInterface; use Drupal\Core\TypedData\Type\StringInterface; @@ -55,19 +54,11 @@ * The configuration name. * @param array $config_data * The configuration data. - * @param array $collection - * The configuration collection. */ + public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data) { - public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data, $collection = StorageInterface::DEFAULT_COLLECTION) { $this->configName = $config_name; if (!$typed_config->hasConfigSchema($config_name)) { + $this->fail(String::format('No schema for !config_name', array('!config_name' => $config_name))); - if ($collection != StorageInterface::DEFAULT_COLLECTION) { - $msg = 'No schema for !config_name in !collection collection'; - } - else { - $msg = 'No schema for !config_name'; - } - $this->fail(String::format($msg, array('!config_name' => $config_name, '!collection' => $collection))); return; } $definition = $typed_config->getDefinition($config_name); @@ -77,13 +68,7 @@ $this->checkValue($key, $value); } if ($this->configPass) { + $this->pass(String::format('Schema found for !config_name and values comply with schema.', array('!config_name' => $config_name))); - if ($collection != StorageInterface::DEFAULT_COLLECTION) { - $msg = 'Schema found for !config_name in !collection collection and values comply with schema.'; - } - else { - $msg = 'Schema found for !config_name and values comply with schema.'; - } - $this->pass(String::format($msg, array('!config_name' => $config_name, '!collection' => $collection))); } } diff -u b/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php b/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php --- b/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/DefaultConfigTest.php @@ -9,7 +9,6 @@ use Drupal\config_test\TestInstallStorage; use Drupal\Core\Config\InstallStorage; -use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\TypedConfigManager; /** @@ -51,27 +50,21 @@ // every module, profile and theme. $default_config_storage = new TestInstallStorage(); - $collections = $default_config_storage->getAllCollectionNames(); - array_unshift($collections, StorageInterface::DEFAULT_COLLECTION); - - foreach ($collections as $collection) { - $default_config_storage = $default_config_storage->createCollection($collection); - foreach ($default_config_storage->listAll() as $config_name) { - // @todo: remove once migration (https://drupal.org/node/2183957) schemas - // are in. - if (strpos($config_name, 'migrate.migration') === 0) { - continue; - } - - // Skip files provided by the config_schema_test module since that module - // is explicitly for testing schema. - if (strpos($config_name, 'config_schema_test') === 0) { - continue; - } + foreach ($default_config_storage->listAll() as $config_name) { + // @todo: remove once migration (https://drupal.org/node/2183957) schemas + // are in. + if (strpos($config_name, 'migrate.migration') === 0) { + continue; + } - $data = $default_config_storage->read($config_name); - $this->assertConfigSchema($typed_config, $config_name, $data); + // Skip files provided by the config_schema_test module since that module + // is explicitly for testing schema. + if (strpos($config_name, 'config_schema_test') === 0) { + continue; } + + $data = $default_config_storage->read($config_name); + $this->assertConfigSchema($typed_config, $config_name, $data); } } diff -u b/core/modules/language/lib/Drupal/language/Config/LanguageConfigOverride.php b/core/modules/language/lib/Drupal/language/Config/LanguageConfigOverride.php --- b/core/modules/language/lib/Drupal/language/Config/LanguageConfigOverride.php +++ b/core/modules/language/lib/Drupal/language/Config/LanguageConfigOverride.php @@ -37,7 +37,12 @@ * {@inheritdoc} */ public function save() { - $this->preSave(); + // @todo Use configuration schema to validate. + // https://drupal.org/node/2270399 + // Perform basic data validation. + foreach ($this->data as $key => $value) { + $this->validateValue($key, $value); + } $this->storage->write($this->name, $this->data); $this->isNew = FALSE; $this->originalData = $this->data; reverted: --- /dev/null +++ a/core/modules/tour/tests/tour_test/config/install/language.config.it.tour.tour.tour-test.yml @@ -0,0 +1,5 @@ +label: Tour test italian +tips: + tour-test-1: + label: La pioggia cade in spagna + body: Per lo più in pianura. reverted: --- b/core/modules/tour/tests/tour_test/config/install/language/it/tour.tour.tour-test.yml +++ /dev/null @@ -1,6 +0,0 @@ -label: Tour test italian -tips: - tour-test-1: - plugin: text - label: 'La pioggia cade in spagna' - body: 'Per lo più in pianura.'