Skip to content
Snippets Groups Projects
Commit c030577c authored by Andrew Berry's avatar Andrew Berry
Browse files

Merge branch 'add-kernel-param' into 403-404-testbot

Conflicts:
	core/lib/Drupal/Core/ExceptionController.php
parents 9462303b 44fd52ce
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -67,6 +67,6 @@ public function __construct(EventDispatcherInterface $dispatcher, ControllerReso
// Either way, treat it as a server-level error and return an HTTP 500.
// By default, this will be an HTML-type response because that's a decent
// best guess if we don't know otherwise.
$this->dispatcher->addSubscriber(new ExceptionListener(array(new ExceptionController($negotiation), 'execute')));
$this->dispatcher->addSubscriber(new ExceptionListener(array(new ExceptionController($this, $negotiation), 'execute')));
}
}
......@@ -7,6 +7,8 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Exception;
......@@ -17,9 +19,11 @@
*/
class ExceptionController {
protected $kernel;
protected $negotiation;
public function __construct(ContentNegotiation $negotiation) {
public function __construct(HttpKernelInterface $kernel, ContentNegotiation $negotiation) {
$this->kernel = $kernel;
$this->negotiation = $negotiation;
}
......@@ -98,10 +102,9 @@ public function on404Html(FlattenException $exception, Request $request) {
// Do that and sub-call the kernel rather than using meah().
// @TODO: The create() method expects a slash-prefixed path, but we
// store a normal system path in the site_404 variable.
$request = Request::create('/' . $path);
$subrequest = Request::create('/' . $path, 'get', array(), $request->cookies->all(), array(), $request->server->all());
$kernel = new DrupalKernel();
$response = $kernel->handle($request, HttpKernelInterface::SUB_REQUEST);
$response = $this->kernel->handle($subrequest, HttpKernelInterface::SUB_REQUEST);
$response->setStatusCode(404, 'Not Found');
}
else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment