Fixed
Project:
Drupal core
Version:
11.x-dev
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Jul 2015 at 07:54 UTC
Updated:
22 Apr 2026 at 22:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dawehnerNote, this improves not nothing, but it doesn't change the overall time yet, because #2531958: Try to do less in theme_get_settings() on every request also lists all of it.
Diff%
Diff
(microsec)
Diff%
MemUse
Diff
(bytes)
Diff%
PeakMemUse
Diff
(bytes)
Diff%
Comment #2
fabianx commentedIs there a patch to review?
Comment #3
dawehnerEhm sure here it is. Ignore the NID of the patch :)
Comment #5
fabianx commentedLooks great, just need to fix the test failures.
Comment #6
claudiu.cristeaThe problem with the tests is because of the architecture of
ThemeInitialization::getActiveThemeByName(). WhenThemeInitialization::getActiveThemeByName()tries to return a theme that is not installed he callsThemeInitialization::getActiveTheme()with a fake theme calledcore. From my point of view this a bad design but this is not subject of this issue.Comment #7
claudiu.cristeaForgot the interdiff.
Comment #8
dawehnerGood observation ... I'll dig into that later, but yeah we should fix the design there properly.
Comment #9
dawehnerDo you mind opening up an issue for that?
So if its core its disabled? We should have a least some form of documentation
Comment #10
claudiu.cristeaNew issue created #2545192: Don't assign 'core' to a theme that cannot be negotiated or is not in the installed theme list.
Added some docs as you suggested in #9.
Comment #11
claudiu.cristeaOuch!
Comment #13
claudiu.cristeaAccidentally I added the same patch twice in #10. Back to NR.
Comment #14
dawehnerThis looks alright for me now, but yeah I fear we need to provide some benchmarking + beta evaluation to judge whether this is useful.
Note: if you have more themes enabled, (which is the workflow if you have the themekey module, you end up in those kind of problems
Comment #15
claudiu.cristea@dawehner, can you point me to some docs, best practices, writeups on how to provide an acceptable benchmark?
Comment #16
claudiu.cristeaComment #17
wim leersI'm afraid this is a dead end :(
EDIT: tested with 1000 requests to
/contact, as the anon users, with page cache off.Comment #18
dawehnera) to be clear #2531958: Try to do less in theme_get_settings() on every request still has a listInfo call, so this is why things are a bit slower here
b) This doesn't tell us any statistically relevant data, see standard derivation. We need to have more iterations in order to tell something properly
Comment #19
joelpittetHere's what I got with the
/contactas the front page. xdebug and all caching turned off. Twig debug turned off and twig caching still on.Also I enabled all the modules and a few contrib modules too but still accessing that page anonymous so it shouldn't make I difference I'd expect.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=5659123816918&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=5659123816918&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=565918537d922&... 8_0_x-summary..themeaccesscheck-summary
Comment #24
joelpittet@claudiu.cristea is there something else we could test directly because page hits aren't significantly different it seems from the tests above.
Setting to NW for update to profiling scenario/instructions.
Comment #34
andypostComment #36
catchThis is still valid, but we have a container parameter with a list of themes now, so I can't see a reason not to use that.
Comment #38
catchAttaching xhprof (xhgui) screenshots. This appears to save about 1ms from each request, the call chain is via the theme cache context.
Comment #39
longwaveOne of the Nightwatch tests consistently fails while trying to install a theme, so I wonder if this has a subtle side effect somewhere?
Comment #40
catchThe nightwatch failure is because the nightwatch install theme command relies on a controller that changes the default/admin theme in a GET request then immediately renders a response - the active theme is determined after the new theme is installed, but the ThemeAccess service isn't refreshed with the new container parameter afaik.
I can't see any obvious way to force this to be refreshed, or even to workaround it in the test, so for now removed the dependency injection so that the list of themes is got from the container at the very last minute.
Comment #41
godotislateI wonder that if #3481903: Support hooks (Hook attribute) in any registered service can land (though there are some challenges), then services can implement
hook_modules_installed()and/orhook_themes_installed()and refresh their properties from the new container there.Comment #43
longwaveWe don't need an entire support module to handle changing the theme for exactly three Nightwatch tests. MR!15405 removes the module and just uses /admin/appearance to change the theme.
Claude Code wrote the change to drupalEnableTheme.js.
Comment #44
catchOK better explanation (mostly in a code comment now).
Access checkers all get constructed when the event dispatcher needs them - this happens before the controller method is called, e.g. when checking access to the route or similar.
The controller method installs a theme then immediately sets it as the admin theme - and the controller is an admin page.
Theme negotiation happens after the method is called, but the access check service has already been constructed before the controller method is called. This means that the theme isn't in the list of themes passed to the access checker.
This all means we can workaround the bug in the nightwatch test module, I find it very unlikely that any equivalent code exists anywhere else.
There are probably cleaner ways to fix it though:
1. In the theme negotiatior, instead of injecting the access checker service, we could inline the logic - the actual logic is one line. This assumes the theme negotiator will be fresh from the container, which it might not.
2. To be honest I don't understand the point of this access check during theme negotiation altogether - how does an uninstalled theme get passed in the first place? Going to open an issue to look into removing it.
Comment #45
catchStill had the tab open and crossposted with #43.
Dropping the support module seems fine too, although I managed to get things isolated to the support module now so that could also be a follow-up. We have two issues open to replace these nightwatch tests anyway.
Going to open the follow-up to see whether the theme access check is really necessary too.
Comment #46
catchOpened #3584064: Check whether ThemeAccess check during theme negotiation is necessary.
Comment #47
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #48
catchComment #49
catchComment #50
berdirHow do you suggest we proceed with this in light of #3584064: Check whether ThemeAccess check during theme negotiation is necessary? if we remove the need for it entirely or put it in an asser(), do we still do this too?
Comment #51
catchWe need to figure out whether we need bc or not in that issue, so for me I'd go ahead here since it's a simple change, then keep going over there. If we go with an assert() in the other issue, it would be better to assert the simple check added here rather than the logic in HEAD too.
Comment #52
berdirAfter thinking about it, I think it makes sense to do this as well. Especially if we only make it an assert() then it would mean that performance tests would have different results depending on whether or not assert is enabled and profiling is often done with assert on and then could lead people down a wrong path.
Added one question about BC on the constructor. I'd suggest doing this, not really because of possible subclasses but more so for handling updates with an existing container. This would probably break pretty hard when trying to access the site without a cache clear.
Comment #53
catchI don't think we need to provide bc for subclasses, but handling the stale container sounds good. While core updates usually for a container rebuild immediately via the container cache key, some sites set manual deployment identifiers and might forget. Added a commit for that.
Comment #54
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #55
catchComment #56
berdirThanks. For constructor parameters with BC, I prefer not promoting them directly, this means we can't set the type on that because of BC, but I think it's OK either way.
Comment #57
catchYeah I went for 'least amount of change', technically we could use a union type in the constructor, but then the property itself would have the union type so not sure that's much better either. Given the constructor is internal and so is the class (even though it's injected in core, it's a tagged service really) not sure it matters much.
Comment #59
catchI've hidden @longwave's branch with the nightwatch refactor but I added a note on #3553673: Migrate from Nightwatch to Playwright (and phpunit Axe) tests that the playwright conversion should tackle it.
Comment #63
godotislateMade two suggestions and applied them myself because they were minor changes to comments.
Committed and pushed 7a031e3 to main and d3126db to 11.x. Thanks!
Comment #65
godotislate