summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-03-31 19:29:13 (GMT)
committerNathaniel Catchpole2014-03-31 19:29:13 (GMT)
commit7b392ea69eedc6ae2a10f31fe96b390106812b9f (patch)
tree6ceeb1fee0f2b5154e772e1d449a7f6f6109980c
parente16cbbe245cbcebe62886cc4d233d1662db44253 (diff)
Issue #2229223 by sun: RequestStack is not persisted across kernel rebuilds.
-rw-r--r--core/core.services.yml2
-rw-r--r--core/includes/install.core.inc1
-rw-r--r--core/includes/install.inc1
-rw-r--r--core/modules/simpletest/lib/Drupal/simpletest/TestBase.php12
-rw-r--r--core/update.php4
5 files changed, 19 insertions, 1 deletions
diff --git a/core/core.services.yml b/core/core.services.yml
index 07f17b9..90c40a9 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -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']
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 616637c..aa158a2 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -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'])) {
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 8ba52b6..e7e5206 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -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');
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 0d80c36..6558f20 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -1140,6 +1140,12 @@ abstract class TestBase {
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 @@ abstract class TestBase {
$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());
}
diff --git a/core/update.php b/core/update.php
index 8f7c325..45904a2 100644
--- a/core/update.php
+++ b/core/update.php
@@ -340,7 +340,9 @@ new Settings($settings);
$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);