diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index d8b77c6..b24f12a 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -573,9 +573,7 @@ public function prepareLegacyRequest(Request $request) { $this->preHandle($request); // Setup services which are normally initialized from within stack // middleware or during the request kernel event. - if (PHP_SAPI !== 'cli') { - $request->setSession($this->container->get('session')); - } + $request->setSession($this->container->get('session')); $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('')); $request->attributes->set(RouteObjectInterface::ROUTE_NAME, ''); $this->container->get('request_stack')->push($request); @@ -722,11 +720,11 @@ protected function initializeContainer($rebuild = FALSE) { $this->container->get('session_manager')->start(); } - // The request stack is preserved accross container rebuilds. Reinject the + // The request stack is preserved across container rebuilds. Reinject the // new session into the master request if one was present before. if (($request_stack = $this->container->get('request_stack', ContainerInterface::NULL_ON_INVALID_REFERENCE))) { if ($request = $request_stack->getMasterRequest()) { - if ($request->hasSession()) { + if (!$request->hasSession()) { $request->setSession($this->container->get('session')); } } diff --git a/core/lib/Drupal/Core/StackMiddleware/Session.php b/core/lib/Drupal/Core/StackMiddleware/Session.php index 0fb786a..b59fb42 100644 --- a/core/lib/Drupal/Core/StackMiddleware/Session.php +++ b/core/lib/Drupal/Core/StackMiddleware/Session.php @@ -54,7 +54,7 @@ public function __construct(HttpKernelInterface $http_kernel, $service_name = 's * {@inheritdoc} */ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) { - if ($type === self::MASTER_REQUEST && PHP_SAPI !== 'cli') { + if ($type === self::MASTER_REQUEST) { $request->setSession($this->container->get($this->sessionServiceName)); } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 4e35b28..398909f 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -32,7 +32,8 @@ $request = Request::createFromGlobals(); $kernel = TestRunnerKernel::createFromRequest($request, $autoloader); -$kernel->prepareLegacyRequest($request); +$kernel->boot(); +$kernel->loadLegacyIncludes();; if ($args['execute-test']) { simpletest_script_setup_database();