diff -u b/core/includes/config.inc b/core/includes/config.inc --- b/core/includes/config.inc +++ b/core/includes/config.inc @@ -114,7 +114,10 @@ * This allows configuration objects to be created using special configuration * contexts eg. global override free or locale using a user preferred language. * Calling this function affects all subsequent calls to config() until - * drupal_container()->get('config.context.factory')->leaveContext() is called. + * config_context_leave() is called. + * + * @see config_context_leave() + * @see \Drupal\Core\Config\ConfigFactory * * @param string $context_name * The name of the config context service on the container or a fully @@ -141,6 +144,18 @@ return $context; } +/* + * Leaves the current config context returning to the previous context. + * + * @see config_context_enter() + * @see \Drupal\Core\Config\ConfigFactory + */ +function config_context_leave() { + drupal_container() + ->get('config.factory') + ->leaveContext(); +} + /** * Returns a list of differences between configuration storages. * 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 @@ -51,7 +51,7 @@ $this->assertIdentical($config_admin->get('foo'), 'bar'); // Leave the non override context. - drupal_container()->get('config.factory')->leaveContext(); + config_context_leave(); $config = config($name); $this->assertIdentical($config->get('foo'), 'en bar'); } diff -u b/core/modules/user/user.module b/core/modules/user/user.module --- b/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1767,7 +1767,9 @@ $token_options = array('langcode' => $langcode, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE); $message['subject'] .= token_replace($mail_config->get($key . '.subject'), $variables, $token_options); $message['body'][] = token_replace($mail_config->get($key . '.body'), $variables, $token_options); - drupal_container()->get('config.factory')->leaveContext(); + + // Return the previous config context. + config_context_leave(); } /**