Commit 7b392ea6 authored by catch's avatar catch

Issue #2229223 by sun: RequestStack is not persisted across kernel rebuilds.

parent e16cbbe2
......@@ -225,6 +225,8 @@ services:
synchronized: true
request_stack:
class: Symfony\Component\HttpFoundation\RequestStack
tags:
- { name: persist }
event_dispatcher:
class: Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
arguments: ['@service_container']
......
......@@ -366,6 +366,7 @@ function install_begin_request(&$install_state) {
$container = $kernel->getContainer();
$container->enterScope('request');
$container->set('request', $request, 'request');
$container->get('request_stack')->push($request);
// Register the file translation service.
if (isset($GLOBALS['config']['locale.settings']['translation.path'])) {
......
......@@ -646,6 +646,7 @@ function drupal_install_system($install_state) {
if ($request) {
$kernel->getContainer()->enterScope('request');
$kernel->getContainer()->set('request', $request, 'request');
$kernel->getContainer()->get('request_stack')->push($request);
}
$system_path = drupal_get_path('module', 'system');
......
......@@ -1140,6 +1140,12 @@ private function prepareEnvironment() {
protected function rebuildContainer($environment = 'testing') {
// Preserve the request object after the container rebuild.
$request = \Drupal::request();
// When called from InstallerTestBase, the current container is the minimal
// container from TestBase::prepareEnvironment(), which does not contain a
// request stack.
if (\Drupal::getContainer()->initialized('request_stack')) {
$request_stack = \Drupal::service('request_stack');
}
$this->kernel = new DrupalKernel($environment, drupal_classloader(), FALSE);
$this->kernel->boot();
......@@ -1148,6 +1154,12 @@ protected function rebuildContainer($environment = 'testing') {
$this->container = \Drupal::getContainer();
// The current user is set in TestBase::prepareEnvironment().
$this->container->set('request', $request);
if (isset($request_stack)) {
$this->container->set('request_stack', $request_stack);
}
else {
$this->container->get('request_stack')->push($request);
}
$this->container->get('current_user')->setAccount(\Drupal::currentUser());
}
......
......@@ -340,7 +340,9 @@ function update_task_list($active = NULL) {
$kernel = new DrupalKernel('update', drupal_classloader(), FALSE);
$kernel->boot();
$request = Request::createFromGlobals();
\Drupal::getContainer()->set('request', $request);
$container = \Drupal::getContainer();
$container->set('request', $request);
$container->get('request_stack')->push($request);
// Determine if the current user has access to run update.php.
drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment