Problem/Motivation
404 and 403 pages are broken. They return Invalid content type requested.
Steps to reproduce
1. Configure custom 404 and 403 pages on admin/config/system/site-information.
2. Visit a non-existent path.
Proposed resolution
The issue lies in handleClientErrorResponses method of CustomElementsViewSubscriber class. Condition to get route name doesn't match `system.4*` because request is forwarded to the node that is a custom error page. Another way to check whether we were redirected to 40x page is by checking the status code query parameter that is added in makeSubrequest method. We also have to change the way custom element slot is set, because $result is render array and doesn't yet have #markup attribute.
I'm not sure that first if condition is still necessary, but I left it in for backwards compatibility.
if (!$result instanceof CustomElement) {
$status_code = $event->getRequest()->get('_exception_statuscode');
if (strpos($this->getCurrentRouteMatch()->getRouteName(), 'system.4') === 0) {
$event->setControllerResult(CustomElement::create('drupal-markup')
->setSlot('default', $result['#markup'])
);
}
elseif (isset($status_code) && in_array($status_code, [401, 403, 404])) {
$event->setControllerResult(CustomElement::create('drupal-markup')
->setSlotFromRenderArray('default', $result)
);
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3177567-2-lupus_ce_renderer_404-pages.patch | 1.4 KB | useernamee |
Issue fork lupus_ce_renderer-3177567
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
useernamee commentedHere is a patch.
Comment #3
fagoThe patch looks good and works exactly as it should. Ready to go.
Comment #6
mostepaniukvmComment #7
mostepaniukvm