diff --git a/core/authorize.php b/core/authorize.php index 5b0a09e00d..10126d9548 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -27,6 +27,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Drupal\Core\Site\Settings; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\Routing\Route; // Change the directory to the Drupal root. chdir('..'); @@ -67,10 +69,15 @@ function authorize_access_allowed(Request $request) { $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod'); $kernel->boot(); $kernel->preHandle($request); + $container = $kernel->getContainer(); // Ensure our request includes the session if appropriate. if (PHP_SAPI !== 'cli') { - $request->setSession($kernel->getContainer()->get('session')); + $request->setSession($container->get('session')); } + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('')); + $request->attributes->set(RouteObjectInterface::ROUTE_NAME, ''); + $container->get('request_stack')->push($request); + $container->get('router.request_context')->fromRequest($request); } catch (HttpExceptionInterface $e) { $response = new Response('', $e->getStatusCode()); diff --git a/core/includes/utility.inc b/core/includes/utility.inc index ceaf55a159..c3fc86fee1 100644 --- a/core/includes/utility.inc +++ b/core/includes/utility.inc @@ -35,8 +35,6 @@ function drupal_rebuild($class_loader, Request $request) { // Bootstrap up to where caches exist and clear them. $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. diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php index 0553f87782..7f3b067a9e 100644 --- a/core/lib/Drupal/Core/DrupalKernelInterface.php +++ b/core/lib/Drupal/Core/DrupalKernelInterface.php @@ -133,7 +133,7 @@ public function invalidateContainer(); * @return $this * * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use - * DrupalKernel::boot() and DrupalKernel::preHandle() instead. + * DrupalKernel::boot() and DrupalKernel::preHandle() instead. */ public function prepareLegacyRequest(Request $request); diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 97994a0b91..e7c79f380a 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -27,9 +27,6 @@ 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.