This is a split from #2538970: Improve the speed of \Drupal\Core\Theme\ThemeAccessCheck.
Problem/Motivation
Right now, if no theme could be negotiated, or if the negotiated theme is not within the list of installed themes, ThemeInitialization::getActiveThemeByName()
, returns a theme having the hardcoded name core
and the path /core/core.info.yml
.
Proposed resolution
Return NULL
as theme name and path for such cases. Make the theme with status = FALSE
in getActiveThemeByName()
(not in getActiveTheme()
).
Remaining tasks
None.
User interface changes
None.
API changes
Fallback theme name not hardcoded.
Take care also to not break the next requirements, from getActiveThemeByName()
:
// If no theme could be negotiated, or if the negotiated theme is not within
// the list of installed themes, fall back to the default theme output of
// core and modules (like Stark, but without a theme extension at all). This
// is possible, because loadActiveTheme() always loads the Twig theme
// engine. This is desired, because missing or malformed theme configuration
// should not leave the application in a broken state. By falling back to
// default output, the user is able to reconfigure the theme through the UI.
// Lastly, tests are expected to operate with no theme by default, so as to
// only assert the original theme output of modules (unless a test manually
// installs a specific theme).
Data model changes
When a valid theme cannot be se as active, the fallback theme name and path are NULL
(not core
and /core/core.info.yml
).
Comments
Comment #1
claudiu.cristeaOn #2538970: Improve the speed of \Drupal\Core\Theme\ThemeAccessCheck.
Comment #2
joelpittetBumping to 8.1 as this may be a bit disruptive for a patch release. Though I'm a fan of the idea.
@claudiu.cristea maybe you could throw a POC code up to get the ball rolling?
Comment #7
joelpittetWhy would providing NULL instead of 'core' help? The templates provided are from 'core' if there isn't a theme.
Comment #16
larowlanThanks for reporting this issue. We rely on issue reports like this one to resolve bugs and improve Drupal core.
As part of the Bug Smash Initiative, we are triaging issues that are marked "Postponed (maintainer needs more info)". This issue was marked "Postponed (maintainer needs more info)" 5 years ago.
In #7 Joel points out that this is by design. Closing on that basis as there has been no further info provided
Comment #17
larowlan