diff -u b/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php --- b/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -912,11 +912,6 @@ } \Drupal::setContainer($this->container); - // If there is a request stack, we want to make sure other parts of the - // codebase can react to this. - if ($request) { - $this->container->get('event_dispatcher')->dispatch(self::CONTAINER_INITIALIZE_FINISHED); - } // If needs dumping flag was set, dump the container. if ($this->containerNeedsDumping && !$this->cacheDrupalContainer($container_definition)) { @@ -924,6 +919,7 @@ if ($request->hasSession()) { $request->setSession($this->container->get('session')); } + $this->container->get('event_dispatcher')->dispatch(self::CONTAINER_INITIALIZE_SUBREQUEST_FINISHED); } } diff -u b/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php --- b/core/lib/Drupal/Core/DrupalKernelInterface.php +++ b/core/lib/Drupal/Core/DrupalKernelInterface.php @@ -15,14 +15,14 @@ interface DrupalKernelInterface extends HttpKernelInterface, ContainerAwareInterface { /** - * Name of the event fired when the service container finished initializing. + * Event fired when the service container finished initializing in subrequest. * * This event allows you to initialize overrides such as language to the * services. * * @var string */ - const CONTAINER_INITIALIZE_FINISHED = 'kernel.container.finish_container_initialize'; + const CONTAINER_INITIALIZE_SUBREQUEST_FINISHED = 'kernel.container.finish_container_initialize_subrequest'; /** * Boots the current kernel. diff -u b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php --- b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php +++ b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php @@ -79,7 +79,7 @@ /** * Initializes config overrides whenever the service container is rebuilt. */ - public function onContainerInitializeFinished() { + public function onContainerInitializeSubrequestFinished() { $this->setLanguageOverrides(); } @@ -106,7 +106,7 @@ */ public static function getSubscribedEvents() { $events[KernelEvents::REQUEST][] = ['onKernelRequestLanguage', 255]; - $events[DrupalKernelInterface::CONTAINER_INITIALIZE_FINISHED][] = array('onContainerInitializeFinished', 255); + $events[DrupalKernelInterface::CONTAINER_INITIALIZE_SUBREQUEST_FINISHED][] = ['onContainerInitializeSubrequestFinished', 255]; return $events; }