reverted: --- b/core/lib/Drupal/Core/Config/Devel/ConfigSchemaChecker.php +++ a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php @@ -2,10 +2,10 @@ /** * @file + * Contains \Drupal\Core\Config\Testing\ConfigSchemaChecker. - * Contains \Drupal\Core\Config\Devel\ConfigSchemaChecker. */ +namespace Drupal\Core\Config\Testing; -namespace Drupal\Core\Config\Devel; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Config\ConfigCrudEvent; diff -u b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php --- b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php @@ -2,12 +2,19 @@ /** * @file - * Contains \Drupal\Core\Config\Testing\ConfigSchemaChecker. + * Contains \Drupal\Core\Config\Development\ConfigSchemaChecker. */ -namespace Drupal\Core\Config\Testing; +namespace Drupal\Core\Config\Development; -use Drupal\Core\Config\Devel\ConfigSchemaChecker as SchemaChecker; +use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Config\ConfigCrudEvent; +use Drupal\Core\Config\ConfigEvents; +use Drupal\Core\Config\Schema\SchemaCheckTrait; +use Drupal\Core\Config\Schema\SchemaIncompleteException; +use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Config\TypedConfigManagerInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Listens to the config save event and validates schema. @@ -20,7 +27,85 @@ * @see \Drupal\simpletest\KernelTestBase::containerBuild() - * - * @deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. - * Use Drupal\Core\Config\Devel\ConfigSchemaChecker. */ -class ConfigSchemaChecker extends SchemaChecker { +class ConfigSchemaChecker implements EventSubscriberInterface { + use SchemaCheckTrait; + + /** + * The typed config manger. + * + * @var \Drupal\Core\Config\TypedConfigManagerInterface + */ + protected $typedManager; + + /** + * An array of config checked already. Keyed by config name and a checksum. + * + * @var array + */ + protected $checked = array(); + + /** + * An array of config object names that are excluded from schema checking. + * + * @var string[] + */ + protected $exclude = array(); + + /** + * Constructs the ConfigSchemaChecker object. + * + * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_manager + * The typed config manager. + * @param string[] $exclude + * An array of config object names that are excluded from schema checking. + */ + public function __construct(TypedConfigManagerInterface $typed_manager, array $exclude = array()) { + $this->typedManager = $typed_manager; + $this->exclude = $exclude; + } + + /** + * Checks that configuration complies with its schema on config save. + * + * @param \Drupal\Core\Config\ConfigCrudEvent $event + * The configuration event. + * + * @throws \Drupal\Core\Config\Schema\SchemaIncompleteException + * Exception thrown when configuration does not match its schema. + */ + public function onConfigSave(ConfigCrudEvent $event) { + // Only validate configuration if in the default collection. Other + // collections may have incomplete configuration (for example language + // overrides only). These are not valid in themselves. + $saved_config = $event->getConfig(); + if ($saved_config->getStorage()->getCollectionName() != StorageInterface::DEFAULT_COLLECTION) { + return; + } + + $name = $saved_config->getName(); + $data = $saved_config->get(); + $checksum = hash('crc32b', serialize($data)); + if (!in_array($name, $this->exclude) && !isset($this->checked[$name . ':' . $checksum])) { + $this->checked[$name . ':' . $checksum] = TRUE; + $errors = $this->checkConfigSchema($this->typedManager, $name, $data); + if ($errors === FALSE) { + throw new SchemaIncompleteException("No schema for $name"); + } + elseif (is_array($errors)) { + $text_errors = []; + foreach ($errors as $key => $error) { + $text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error)); + } + throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors)); + } + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[ConfigEvents::SAVE][] = array('onConfigSave', 255); + return $events; + } + } diff -u b/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php --- b/core/modules/config/src/Tests/ConfigCRUDTest.php +++ b/core/modules/config/src/Tests/ConfigCRUDTest.php @@ -26,7 +26,7 @@ /** * Exempt from strict schema checking. * - * @see \Drupal\Core\Config\Devel\ConfigSchemaChecker + * @see \Drupal\Core\Config\Development\ConfigSchemaChecker * * @var bool */ diff -u b/core/modules/config/src/Tests/ConfigEntityUnitTest.php b/core/modules/config/src/Tests/ConfigEntityUnitTest.php --- b/core/modules/config/src/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/src/Tests/ConfigEntityUnitTest.php @@ -19,7 +19,7 @@ /** * Exempt from strict schema checking. * - * @see \Drupal\Core\Config\Devel\ConfigSchemaChecker + * @see \Drupal\Core\Config\Development\ConfigSchemaChecker * * @var bool */ diff -u b/core/modules/config/src/Tests/ConfigFileContentTest.php b/core/modules/config/src/Tests/ConfigFileContentTest.php --- b/core/modules/config/src/Tests/ConfigFileContentTest.php +++ b/core/modules/config/src/Tests/ConfigFileContentTest.php @@ -20,7 +20,7 @@ /** * Exempt from strict schema checking. * - * @see \Drupal\Core\Config\Devel\ConfigSchemaChecker + * @see \Drupal\Core\Config\Development\ConfigSchemaChecker * * @var bool */ diff -u b/core/modules/config/src/Tests/SchemaConfigListenerTest.php b/core/modules/config/src/Tests/SchemaConfigListenerTest.php --- b/core/modules/config/src/Tests/SchemaConfigListenerTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerTest.php @@ -23,7 +23,7 @@ public static $modules = array('config_test'); /** - * Tests \Drupal\Core\Config\Devel\ConfigSchemaChecker. + * Tests \Drupal\Core\Config\Development\ConfigSchemaChecker. */ public function testConfigSchemaChecker() { // Test a non-existing schema. diff -u b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php --- b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php @@ -23,7 +23,7 @@ public static $modules = array('config_test'); /** - * Tests \Drupal\Core\Config\Devel\ConfigSchemaChecker. + * Tests \Drupal\Core\Config\Development\ConfigSchemaChecker. */ public function testConfigSchemaChecker() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); diff -u b/core/modules/config/tests/config_test/src/SchemaListenerController.php b/core/modules/config/tests/config_test/src/SchemaListenerController.php --- b/core/modules/config/tests/config_test/src/SchemaListenerController.php +++ b/core/modules/config/tests/config_test/src/SchemaListenerController.php @@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Controller for testing \Drupal\Core\Config\Devel\ConfigSchemaChecker. + * Controller for testing \Drupal\Core\Config\Development\ConfigSchemaChecker. */ class SchemaListenerController extends ControllerBase { diff -u b/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php --- b/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -320,7 +320,7 @@ if ($this->strictConfigSchema) { $container - ->register('simpletest.config_schema_checker', 'Drupal\Core\Config\Devel\ConfigSchemaChecker') + ->register('simpletest.config_schema_checker', 'Drupal\Core\Config\Development\ConfigSchemaChecker') ->addArgument(new Reference('config.typed')) ->addArgument($this->getConfigSchemaExclusions()) ->addTag('event_subscriber'); diff -u b/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php --- b/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -288,7 +288,7 @@ /** * Set to TRUE to strict check all configuration saved. * - * @see \Drupal\Core\Config\Devel\ConfigSchemaChecker + * @see \Drupal\Core\Config\Development\ConfigSchemaChecker * * @var bool */ diff -u b/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php --- b/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -778,7 +778,7 @@ $content = file_get_contents($directory . '/services.yml'); $services = $yaml->parse($content); $services['services']['simpletest.config_schema_checker'] = [ - 'class' => 'Drupal\Core\Config\Devel\ConfigSchemaChecker', + 'class' => 'Drupal\Core\Config\Development\ConfigSchemaChecker', 'arguments' => ['@config.typed', $this->getConfigSchemaExclusions()], 'tags' => [['name' => 'event_subscriber']] ]; diff -u b/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php --- b/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -185,7 +185,7 @@ /** * Set to TRUE to strict check all configuration saved. * - * @see \Drupal\Core\Config\Devel\ConfigSchemaChecker + * @see \Drupal\Core\Config\Development\ConfigSchemaChecker * * @var bool */ @@ -576,7 +576,7 @@ if ($this->strictConfigSchema) { $container - ->register('simpletest.config_schema_checker', 'Drupal\Core\Config\Devel\ConfigSchemaChecker') + ->register('simpletest.config_schema_checker', 'Drupal\Core\Config\Development\ConfigSchemaChecker') ->addArgument(new Reference('config.typed')) ->addTag('event_subscriber'); } diff -u b/sites/development.services.yml b/sites/development.services.yml --- b/sites/development.services.yml +++ b/sites/development.services.yml @@ -6,7 +6,7 @@ cache.backend.null: class: Drupal\Core\Cache\NullBackendFactory config.checker.schema: - class: Drupal\Core\Config\Devel\ConfigSchemaChecker + class: Drupal\Core\Config\Development\ConfigSchemaChecker arguments: ['@config.typed'] tags: - { name: event_subscriber }