diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index c21f43e..0e679fd 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -573,7 +573,9 @@ public function prepareLegacyRequest(Request $request) { $this->preHandle($request); // Setup services which are normally initialized from within stack // middleware or during the request kernel event. - $request->setSession($this->container->get('session')); + if (PHP_SAPI !== 'cli') { + $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); diff --git a/core/lib/Drupal/Core/StackMiddleware/Session.php b/core/lib/Drupal/Core/StackMiddleware/Session.php index b59fb42..0fb786a 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) { + if ($type === self::MASTER_REQUEST && PHP_SAPI !== 'cli') { $request->setSession($this->container->get($this->sessionServiceName)); } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 52c322b..4e35b28 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -32,11 +32,9 @@ $request = Request::createFromGlobals(); $kernel = TestRunnerKernel::createFromRequest($request, $autoloader); -$kernel->boot(); -$kernel->loadLegacyIncludes(); +$kernel->prepareLegacyRequest($request); if ($args['execute-test']) { - $kernel->prepareLegacyRequest($request); simpletest_script_setup_database(); simpletest_script_run_one_test($args['test-id'], $args['execute-test']); // Sub-process exited already; this is just for clarity.