Problem/Motivation
Followup from #2218039: Render the maintenance/install page like any other HTML page.
Bring file name patterns in line with core standards.
Address theme suggestions as well, for example, page__maintenance
.
Proposed resolution
Use core's template suggestions and rename templates and related preprocess functions
User interface changes
None.
API changes
removal of theme keys maintenance_page
& install_page
Template name changes.
maintenance_page
=> page--maintenance
install_page
=> page--maintenance--install
maintenance_page__offline
=> page__maintenance__offline
preprocess functions moved to system module
template_preprocess_maintenance_page()
=> system_preprocess_page__maintenance()
template_preprocess_install_page
=> system_preprocess_page__maintenance__install()
Beta phase evaluation
Issue category | Task because follow-up and just renames templates and increase TX |
---|---|
Issue priority | Normal because nothing is broken |
Unfrozen changes | Unfrozen because it only changes template names and related preprocess functions |
Disruption | Disruptive for custom modules/themes because it will require a rename templates and preprocess functions if any |
Original report by @jessebeach
Comment | File | Size | Author |
---|---|---|---|
#93 | 2231853-93.patch | 21.54 KB | andypost |
#93 | interdiff.txt | 721 bytes | andypost |
Comments
Comment #1
jessebeach CreditAttribution: jessebeach commentedComment #2
cs_shadow CreditAttribution: cs_shadow commentedRenamed the file and replaced occurrences of 'maintenance-page.html.twig' to 'page--maintenance.html.twig' in comments. Attaching a patch for the same.
Comment #3
cs_shadow CreditAttribution: cs_shadow commentedComment #4
sunThanks! #2218039: Render the maintenance/install page like any other HTML page should land first though. Hopefully this patch will still apply then.
Comment #6
sunWe additionally need to change the template suggestions, so that the renamed page templates are actually picked up.
Let's merge the patch from #2231857: Rename install-page.html.twig to page--install.html.twig into this here + then figure out how to get the template suggestions to work.
Comment #7
sunOr on a second thought, perhaps we don't actually need to futz with template suggestions...
It might be sufficient to just simply change the #theme property in
Drupal\Core\Page\DefaultHtmlPageRenderer::renderPage()
:Can you try that? :-)
Comment #8
cs_shadow CreditAttribution: cs_shadow commentedThe tests fail because it expects the file named 'maintenance-page template' to be present. Any suggestions on how to solve this instead of manually changing all the tests?
Comment #9
sun@cs_shadow: That is caused by the missing change I mentioned in #7.
Hm. Potential problem:
I wonder whether page--X could conflict with the regular page template suggestions?
For example, if you have a path that is
/install
, then the page template for that path would bepage--install
. (same for /maintenance)Would it be acceptable if we'd use single dashes for these special unicorns? Or shall we ignore that potential problem?
On a second after-thought, a single dash ^^ does not work, because the page template theme suggestions only work with two dashes...
What we want to achieve is that the regular page.html.twig template is used, in case no page--install.html.twig template exists.
→ We actually have to obey to the pattern for theme suggestions, because otherwise, the fallback to 'page' would not work.
Lastly, speaking of fallbacks: The install page is actually a more specific incarnation of the maintenance page.
→ page__maintenance__install
...which causes theme template suggestions to be applied in this order:
→ page--maintenance--install.html.twig
→ page--maintenance.html.twig
→ page.html.twig
Comment #10
sunAfter some back and forth, the parent issue has landed (again): #2218039: Render the maintenance/install page like any other HTML page
Let's move forward here! Any ideas/feedback on #9, anyone?
Comment #11
sunSo attached patch performs the main changes...
...but doing so causes us to inherently run into the problem space of #939462: Specific preprocess functions for theme hook suggestions are not invoked
:-/
Comment #13
sunI just stumbled over #2231505: Convert theme_field__node__title() to Twig, which implements a custom/cumbersome workaround in
hook_theme()
that could seemingly work here, too:Comment #14
star-szrThat issue didn't implement it (just added the 'template' line) but yes that is totally valid as a workaround for #939462: Specific preprocess functions for theme hook suggestions are not invoked :)
The /maintenance template suggestion clash is still a bit concerning to me as a "gotcha" here.
Comment #15
effulgentsia CreditAttribution: effulgentsia commentedIs this an acceptable interim step to #939462: Specific preprocess functions for theme hook suggestions are not invoked that's sufficient to unblock this issue?
Comment #17
effulgentsia CreditAttribution: effulgentsia commentedComment #19
effulgentsia CreditAttribution: effulgentsia commented17: template.maintenance.17.patch queued for re-testing.
Comment #20
effulgentsia CreditAttribution: effulgentsia commentedGreen, so back to needs review.
Just to clarify, in HEAD, *_preprocess_maintenance_page() ran instead of *_preprocess_page(), because it was a fully separate theme hook. With this patch, *_preprocess_page__maintenance() runs in addition to *_preprocess_page(). Is there any code within the preprocess functions that we want to adjust as a result of that?
Comment #21
sunBased on my studies, the install + maintenance preprocess functions should work as-is (and actually better + more accurately) with that inheritance.
However, I think I have to object to the proposed stop-gap change. I'd be inclined to agree if it wasn't a major API change. Changing that parameter to be a
$context
looks clunky and is in no way guaranteed to be the final API.$context
is hard enough to figure out for PHP/module developers already; I do not want to introduce a$context
parameter in the theme space. Therefore, I'd like to push back on that; let's resolve the preprocess issue first.With regard to temporary stop-gap workarounds, only the hack referenced in #13 (which apparently exists in HEAD already) would work for me.
Comment #22
effulgentsia CreditAttribution: effulgentsia commentedLet's finalize it here then (or a spin-off, but not one that needs to wait for all of #939462: Specific preprocess functions for theme hook suggestions are not invoked). Regardless of that issue's scope to run suggestion-specific preprocessors automatically, I think we'll still want a way to inform the base preprocess functions of what suggestion(s) are also involved, in the same way we currently inform the preprocessors of $hook. Similar to how in OOP, a base class can inspect
get_class($this)
if it really needs to. I thought $context would be preferable to$hook, $info, $suggestions, $suggestion
all being individual parameters. Do you have a better suggestion (heh, no pun intended)?Comment #23
sunHow does that not duplicate the whole point of that issue to 100%?
We'd only repeat the whole discussion from scratch. And, by only looking at this isolated deeper aspect, I'm highly concerned that we'd only duct-tape without having a good understanding of whether the resulting change doesn't make the overall situation worse instead of better. The proposed clean-up of this issue here doesn't provide sufficient justification for such a risk.
What I could agree with would be an effort to restart that issue from a clean slate, because yes, that issue is very lengthy, complex, and cumbersome; it requires multiple hours to fully process (+ validate) all input and data in all comments, so as to fully understand all involved aspects and most importantly, expectations of themers (as well as module developers). I vaguely remember very well that just doing that analysis took me half a day back in 2012/2013 when I last studied it (which was before the extremely debatable
hook_theme_suggestions()
+_alter()
was introduced; FWIW, a total performance drain, as some of the theme registry logic has been moved into the runtime layer and so that's re-executed from scratch for every. single. call. to. theme.).In short, the theme system "very badly needs us." I guess it's that crew again. ;-)
Comment #24
Jalandhar CreditAttribution: Jalandhar commentedPatch #17, needs to be updated.
Comment #25
Jalandhar CreditAttribution: Jalandhar commentedComment #26
andypostComment #27
pguillard CreditAttribution: pguillard commentedJust tried reroll #17 the best I can...
Comment #29
madhavvyas CreditAttribution: madhavvyas as a volunteer commentedPatch re rolled for comment 27
Comment #30
madhavvyas CreditAttribution: madhavvyas as a volunteer commentedPatch re rolled for comment 27
Comment #32
Antti J. Salminen CreditAttribution: Antti J. Salminen as a volunteer commentedWorked a bit on this, starting with pguillard's reroll from #27. The preprocess issue should be fixed now so we only need to declare the implementations in hook_theme. Still needs work (the suggestion hook for offline and possibly changes for the preprocess functions) but marking needs review to see how functional it is.
Comment #35
Antti J. Salminen CreditAttribution: Antti J. Salminen as a volunteer commentedLooks like the patch still applies and the tests pass now that #2565259: Some route serializations in update test database dumps are broken is in.
Comment #36
Antti J. Salminen CreditAttribution: Antti J. Salminen as a volunteer commentedComment #37
andypostrename classy template and clean-ups
is this still needed? suppose not after #939462: Specific preprocess functions for theme hook suggestions are not invoked
suppose hook_preprocess_page__m...
Comment #40
andypostfix css, and move template preprocess functions to system
Also merged
system_theme_suggestions_page()
andsystem_theme_suggestions_maintenance_page()
EDIT
without theme-key this is not invoked so moved to preprocess
Comment #41
lauriiiComment #42
andypostUpdated IS and added beta eval
Comment #43
lauriiiI tested manually update.php, maintenance mode and installer and everything seems to be fine with those. I discussed with @andypost and @davidhernandez that renaming CSS files even though the CSS files have changed is not necessary because the current names makes more sense than anything else we could quickly figure out.
Comment #44
davidhernandezI think changing somewhat major template names could do with a change record.
Comment #45
andypostCR https://www.drupal.org/node/2567567
Comment #46
lauriiiCR looks good.
Sorry I didn't see this before but these should be still prefixed with template_. Also the @see is pointing for template prefixed version :)
Comment #47
andypostTo make them work as
template_
we need to keep theme keysnot sure it makes sense and this preprocess adds a system library
Comment #48
lauriiiI'm sorry but what do you mean by theme keys?
Comment #49
andypostthis ones that are removed in #37
Comment #50
lauriiiI filed #2567693: Specific preprocess functions not picked up for template_ prefix for template_ prefixed preprocess functions not being picked up. We can use the hook_preprocess_* functions but we should add @todo's to fix them after the bug has been fixed. Also the documentation should be pointing on the right preprocess functions.
Comment #51
davidhernandez@lauriii
Which lines of documentation are you referring to?
Comment #52
lauriiiI thought I saw some wrong preprocess functions being mentioned in the docblocks but couldn't find that at least now
Comment #54
pguillard CreditAttribution: pguillard commented#40 rerolled, as it was not applying anymore
Comment #58
andypostlooks that should go to 8.1
Comment #59
joelpittetagreed
Comment #60
hass CreditAttribution: hass commentedIsn't this not a BC break that need to wait until D9? Themes that implemented it in 8.0 will break in 8.1.
Comment #61
joelpittetIf we can't put in a BC layer then yes, D9. Would like to give the opportunity if it's feasible.
Comment #62
andypostany idea about BC shim here?
we can't change stable theme anymore til 9.x...
so that needs general idea how to move forward
Comment #68
andypostAs for BC
- keep old theme function & preprocess
- maybe use theme suggestion to provide ordered list with new theme key before old implementation
- keep fallback for old template ( cos some distros use custom maintenance page
Comment #72
andypostComment #73
pguillard CreditAttribution: pguillard commentedHere is a re-rolled patch. (Worked on the reroll only)
Comment #74
pguillard CreditAttribution: pguillard commentedComment #76
andypostNow it needs changes after https://www.drupal.org/node/2960810
Comment #77
AjitS@pguillard - Thank you for the reroll. It is adviced that once you reroll the patch you remove the "Needs reroll" tag.
Comment #80
andypostHere's a re-roll + fix of test (checksum) and claro parts
EDIT other tests fails because no title (H1 tag) displayed)
Comment #86
andypostLooks that 10.x material
Comment #87
quietone CreditAttribution: quietone at PreviousNext commentedJust a reroll. There was nothing complicated.
Comment #88
quietone CreditAttribution: quietone at PreviousNext commentedYes, I didn't run the checks.
Comment #90
andypostfix css for claro, but language selection still has label hidden (that's why
InstallerTest
fails)Comment #91
andypostfix CS
Comment #93
andypostLooks Claro needs more fixes and not clear about default config test