4xx HTTP code theme suggestions are not applied if a node is set as 4xx path

Created on 18 July 2023, 11 months ago
Updated 20 September 2023, 9 months ago

Problem/Motivation

In #2363987: Add theme support for content of 401/403/404 responses , theme suggestions were added for 4xx routes. During development of the patch, people reported that the solution did not work if a node path was set as 4xx page, but this was ignored/considered acceptable behavior. I don't think this is acceptable behavior, this issue can easily be fixed by changing the implementation.

Steps to reproduce

  1. Set a node/XXX path as 404 page in the admin/config/system/site-information form
  2. Visit the canonical route of the node. No page__404 theme suggestion is provided.

Proposed resolution

Refactor system_theme_suggestions_page to check \Drupal::requestStack()->getCurrentRequest()->attributes->get('exception') for the current response HTTP code. Another example of core code using this parameter is Drupal\Core\Menu\LocalTaskManager::getLocalTasks.

🐛 Bug report
Status

Fixed

Version

10.1

Component
System 

Last updated 2 days ago

No maintainer
Created by

🇧🇪Belgium DieterHolvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024