diff --git a/core/authorize.php b/core/authorize.php
index a72e0ac687..5b0a09e00d 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -65,7 +65,12 @@ function authorize_access_allowed(Request $request) {
 try {
   $request = Request::createFromGlobals();
   $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
-  $kernel->prepareLegacyRequest($request);
+  $kernel->boot();
+  $kernel->preHandle($request);
+  // Ensure our request includes the session if appropriate.
+  if (PHP_SAPI !== 'cli') {
+    $request->setSession($kernel->getContainer()->get('session'));
+  }
 }
 catch (HttpExceptionInterface $e) {
   $response = new Response('', $e->getStatusCode());
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 3529d51a98..6fe1339bb7 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -613,6 +613,7 @@ function drupal_install_system($install_state) {
   // Remove the service provider of the early installer.
   unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']);
 
+  // Get the existing request.
   $request = \Drupal::request();
   // Reboot into a full production environment to continue the installation.
   /** @var \Drupal\Core\Installer\InstallerKernel $kernel */
@@ -620,7 +621,13 @@ function drupal_install_system($install_state) {
   $kernel->shutdown();
   // Have installer rebuild from the disk, rather then building from scratch.
   $kernel->rebuildContainer(FALSE);
-  $kernel->prepareLegacyRequest($request);
+  // Reboot the kernel with new container.
+  $kernel->boot();
+  $kernel->preHandle($request);
+  // Ensure our request includes the session if appropriate.
+  if (PHP_SAPI !== 'cli') {
+    $request->setSession($kernel->getContainer()->get('session'));
+  }
 
   // Install base system configuration.
   \Drupal::service('config.installer')->installDefaultConfig('core', 'core');
diff --git a/core/includes/utility.inc b/core/includes/utility.inc
index 70d74a1ef5..ceaf55a159 100644
--- a/core/includes/utility.inc
+++ b/core/includes/utility.inc
@@ -36,12 +36,17 @@ function drupal_rebuild($class_loader, Request $request) {
   $kernel = new DrupalKernel('prod', $class_loader);
   $kernel->setSitePath(DrupalKernel::findSitePath($request));
 
+  // Prepare a NULL request.
+  $kernel->boot();
+  $kernel->preHandle($request);
+  // Ensure our request includes the session if appropriate.
+  if (PHP_SAPI !== 'cli') {
+    $request->setSession($kernel->getContainer()->get('session'));
+  }
+
   // Invalidate the container.
   $kernel->invalidateContainer();
 
-  // Prepare a NULL request.
-  $kernel->prepareLegacyRequest($request);
-
   foreach (Cache::getBins() as $bin) {
     $bin->deleteAll();
   }
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 217d4dc781..315eda9ab8 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -717,6 +717,7 @@ public function prepareLegacyRequest(Request $request) {
     $request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
     $this->container->get('request_stack')->push($request);
     $this->container->get('router.request_context')->fromRequest($request);
+    @trigger_error(__METHOD__ . ' is deprecated Drupal 8.0.x and will be removed before 9.0.0. Use DrupalKernel::boot() and DrupalKernel::preHandle() instead.', E_USER_DEPRECATED);
     return $this;
   }
 
diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php
index ff065a8f82..0553f87782 100644
--- a/core/lib/Drupal/Core/DrupalKernelInterface.php
+++ b/core/lib/Drupal/Core/DrupalKernelInterface.php
@@ -132,8 +132,8 @@ public function invalidateContainer();
    *
    * @return $this
    *
-   * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Only used by
-   *   legacy front-controller scripts.
+   * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use
+   * DrupalKernel::boot() and DrupalKernel::preHandle() instead.
    */
   public function prepareLegacyRequest(Request $request);
 
diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
index f9f97ecaa8..378524c5ad 100644
--- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
+++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
@@ -16,6 +16,8 @@
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Yaml\Yaml as SymfonyYaml;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Symfony\Component\Routing\Route;
 
 /**
  * Defines a trait for shared functional test setup functionality.
@@ -388,10 +390,17 @@ protected function initUserSession() {
    */
   protected function initKernel(Request $request) {
     $this->kernel = DrupalKernel::createFromRequest($request, $this->classLoader, 'prod', TRUE);
-    $this->kernel->prepareLegacyRequest($request);
+    $this->kernel->boot();
+    $this->kernel->preHandle($request);
     // Force the container to be built from scratch instead of loaded from the
     // disk. This forces us to not accidentally load the parent site.
-    return $this->kernel->rebuildContainer();
+    $container = $this->kernel->rebuildContainer();
+    // Add our request to the stack and route context.
+    $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
+    $request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
+    $container->get('request_stack')->push($request);
+    $container->get('router.request_context')->fromRequest($request);
+    return $container;
   }
 
   /**
@@ -441,7 +450,6 @@ protected function rebuildAll() {
     // @todo Test-specific setUp() methods may set up further fixtures; find a
     //   way to execute this after setUp() is done, or to eliminate it entirely.
     $this->resetAll();
-    $this->kernel->prepareLegacyRequest(\Drupal::request());
 
     // Explicitly call register() again on the container registered in \Drupal.
     // @todo This should already be called through
@@ -575,7 +583,8 @@ protected function prepareEnvironment() {
     $kernel = TestRunnerKernel::createFromRequest($request, $this->classLoader);
     // TestRunnerKernel expects the working directory to be DRUPAL_ROOT.
     chdir(DRUPAL_ROOT);
-    $kernel->prepareLegacyRequest($request);
+    $kernel->boot();
+    $kernel->preHandle($request);
     $this->prepareDatabasePrefix();
 
     $this->originalSite = $kernel->findSitePath($request);
diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php
index 92f33dcf5f..7ef6dc2826 100644
--- a/core/modules/simpletest/src/InstallerTestBase.php
+++ b/core/modules/simpletest/src/InstallerTestBase.php
@@ -148,8 +148,13 @@ protected function setUp() {
       // Not using File API; a potential error must trigger a PHP warning.
       chmod($this->container->get('app.root') . '/' . $this->siteDirectory, 0777);
       $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
-      $this->kernel->prepareLegacyRequest($request);
+      $this->kernel->boot();
+      $this->kernel->preHandle($request);
       $this->container = $this->kernel->getContainer();
+      // Ensure our request includes the session if appropriate.
+      if (PHP_SAPI !== 'cli') {
+        $request->setSession($this->container->get('session'));
+      }
 
       // Manually configure the test mail collector implementation to prevent
       // tests from sending out emails and collect them in state instead.
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5ebf9f0c9f..1704e7c9e3 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -55,7 +55,8 @@
 try {
   $request = Request::createFromGlobals();
   $kernel = TestRunnerKernel::createFromRequest($request, $autoloader);
-  $kernel->prepareLegacyRequest($request);
+  $kernel->boot();
+  $kernel->preHandle($request);
 }
 catch (Exception $e) {
   echo (string) $e;
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 3e54b3f085..cda276986f 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -28,6 +28,8 @@
 use Symfony\Component\HttpFoundation\Request;
 use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\visitor\vfsStreamPrintVisitor;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Symfony\Component\Routing\Route;
 
 /**
  * Base class for functional integration tests.
@@ -363,10 +365,14 @@ private function bootKernel() {
     // DrupalKernel::boot() is not sufficient as it does not invoke preHandle(),
     // which is required to initialize legacy global variables.
     $request = Request::create('/');
-    $kernel->prepareLegacyRequest($request);
+    $kernel->boot();
+    $kernel->preHandle($request);
 
-    // register() is only called if a new container was built/compiled.
+    $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
+    $request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
     $this->container = $kernel->getContainer();
+    $this->container->get('request_stack')->push($request);
+    $this->container->get('router.request_context')->fromRequest($request);
 
     // Ensure database tasks have been run.
     require_once __DIR__ . '/../../../includes/install.inc';
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index e7c79f380a..97994a0b91 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -27,6 +27,9 @@
 use Psr\Http\Message\RequestInterface;
 use Psr\Http\Message\ResponseInterface;
 use Symfony\Component\CssSelector\CssSelectorConverter;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Route;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 
 /**
  * Provides a test case for functional Drupal tests.
