diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php index 0d876cc..38cb895 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php @@ -133,6 +133,14 @@ protected function makeSubrequest(GetResponseForExceptionEvent $event, $url, $st // would execute a subrequest with the 404 route's URL, then it'd be // generated for *that* URL, not the *original* URL. $sub_request = clone $request; + + // The routing to the 404 page should be done as GET request because it is + // restricted to GET and POST requests only. Otherwise a DELETE request + // would for example trigger a method not allowed exception. + $request_context = clone ($this->accessUnawareRouter->getContext()); + $request_context->setMethod('GET'); + $this->accessUnawareRouter->setContext($request_context); + $sub_request->attributes->add($this->accessUnawareRouter->match($url)); // Add to query (GET) or request (POST) parameters: