diff -u b/core/includes/config.inc b/core/includes/config.inc --- b/core/includes/config.inc +++ b/core/includes/config.inc @@ -3,7 +3,6 @@ use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\FileStorage; -use Drupal\Core\Config\Context\ContextInterface; use Drupal\Core\Config\StorageInterface; /** @@ -27,8 +26,7 @@ function config_install_default_config($type, $name) { // Use the override free context for config importing so that any overrides do // not change the data on import. - $config_factory = drupal_container()->get('config.factory'); - $config_factory->enterContext(drupal_container()->get('config.context.free')); + config_context_enter('config.context.free'); // If this module defines any ConfigEntity types then create an empty // manifest file for each of them. @@ -55,7 +53,7 @@ } // Exit the override free context and ensure that any new manifest data is // available. - $config_factory + drupal_container()->get('config.factory') ->leaveContext() ->reset('manifest'); } @@ -129,7 +127,7 @@ if (drupal_container()->has($context_name)) { $context = drupal_container()->get($context_name); } - elseif (class_exists($context_name)) { + elseif (class_exists($context_name) && in_array("Drupal\\Core\\Config\\Context\\ContextInterface", class_implements($context_name))) { $context = drupal_container() ->get('config.context.factory') ->get($context_name); @@ -265,15 +263,14 @@ try { // Use the override free context for config importing so that any overrides do // not change the data on import. - $config_factory = drupal_container()->get('config.factory'); - $config_factory->enterContext(drupal_container()->get('config.context.free')); + config_context_enter('config.context.free'); $remaining_changes = config_import_invoke_owner($config_changes, $source_storage, $target_storage); config_sync_changes($remaining_changes, $source_storage, $target_storage); // Exit the override free context and ensure that any new manifest data is // available. - $config_factory + drupal_container()->get('config.factory') ->leaveContext() ->reset('manifest'); } diff -u b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php --- b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php @@ -85,7 +85,7 @@ )); $config_factory = drupal_container()->get('config.factory'); - $user_config_context = config_context_enter('Drupal\user\UserConfigContext'); + $user_config_context = config_context_enter("Drupal\\user\\UserConfigContext"); $user_config_context->setAccount($account); $config = config('config_test.system'); $this->assertIdentical($config->get('foo'), 'fr bar'); @@ -118,7 +118,7 @@ 'preferred_langcode' => 'en', )); // Create a new user config context to stack on top of the existign one. - $en_user_config_context = config_context_enter('Drupal\user\UserConfigContext'); + $en_user_config_context = config_context_enter("Drupal\\user\\UserConfigContext"); $en_user_config_context->setAccount($account); $config = config('config_test.system'); $this->assertIdentical($config->get('foo'), 'en bar'); only in patch2: unchanged: --- a/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigCRUDTest.php @@ -171,21 +171,13 @@ function testNameValidation() { // Write configuration with an invalid name (missing a namespace) to // staging. - $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); $manifest_data = config('manifest.invalid_object_name')->get(); $manifest_data['new']['name'] = 'invalid'; $staging->write('manifest.invalid_object_name', $manifest_data); - // Verify that an exception is thrown when synchronizing. - $message = 'Expected ConfigNameException was thrown when attempting to sync invalid configuration.'; - try { - config_import(); - $this->fail($message); - } - catch (ConfigNameException $e) { - $this->pass($message); - } + // Assert that config_import returns false indicating a failure. + $this->assertFalse(config_import(), "Config import failed when trying to importing an object with an invalid name"); } }