template_preprocess_maintenance_page() simply concatenates '#content' onto the content region:
// Get all region content set with drupal_add_region_content().
foreach (array_keys($regions) as $region) {
// Assign region to a region variable.
$region_content = drupal_get_region_content($region);
isset($variables[$region]) ? $variables[$region] .= $region_content : $variables[$region] = $region_content;
}
This means that '#content' can never be a render array and forces us to always build content for maintenance pages as strings instead of using the Render API.
This issue blocks multiple cleanups for the render API in sections of the site using maintenance pages.
Blocked issues
- #2072639: Convert update_info_page() from a string concatenation function to a render array builder
- #2060401: Remove useless "early render" in authorize.php
- #2060413: remove useless "early render" in update_selection_page()
- #2060441: Convert update_results_page() to return a renderable array rather than early render
- #2088957: title in template_preprocess_maintaince_page should be on 'content' not 'page'
Review Bonus
+2 https://drupal.org/node/855726#comment-8002615
+2 https://drupal.org/node/415710#comment-8002631
-3 tagged in #62
Total: 1
Comment | File | Size | Author |
---|---|---|---|
#75 | interdiff.txt | 855 bytes | star-szr |
#75 | 2072647-74.patch | 7.3 KB | star-szr |
#75 | 2072647-74-testonly.patch | 5.77 KB | star-szr |
#73 | 2072647-72.patch | 7.65 KB | herom |
#73 | interdiff-2072647-69-72.txt | 2.17 KB | herom |
Comments
Comment #1
thedavidmeister CreditAttribution: thedavidmeister commentedpatch.
Comment #1.0
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #2
thedavidmeister CreditAttribution: thedavidmeister commentedComment #4
thedavidmeister CreditAttribution: thedavidmeister commented#1: 2072647-1.patch queued for re-testing.
Comment #5
thedavidmeister CreditAttribution: thedavidmeister commenteddiscussing in IRC, potentially special-casing 'content' and accepting strings or render arrays there:
Comment #6
thedavidmeister CreditAttribution: thedavidmeister commentedHere is a better patch. Discussed this with @alexpott and @catch in IRC.
I have not figured out how to do tests cleanly yet.
Comment #7
jwilson3Its passing, so does this need tests then?
Comment #8
jwilson3This is loosely related to an issue i was working on, and could affect it #713462: Content added via drupal_add_region_content() is not added to pages if it were to get in.
Could we make template_preprocess_maintenance_page() work the same way template_preprocess_page() currently does to build up a render array inside $variables['page']['region_name'] ?
Comment #9
jwilson3I was thinking something like this (if it appears I'm hijacking your issue, I'm not! just tryin to help!
This patch also rearranges a couple lines of code so that when compared side-by-side with template_preprocess_page() after applying it, the similarities are more evident.
It also has the added benefit that if you apply the patch from #713462-19: Content added via drupal_add_region_content() is not added to pages, the for loop code is exactly the same between preprocess_page and preprocess_maintenance_page :)
Comment #11
jwilson3Bah. sorry.
Comment #12
jwilson3interdiff between #8-#11.
Comment #14
jwilson3So it appears that introducing everything underneath $variables['page'] (as is done in preprocesS_page) pretty much breaks everything :P
Perhaps just removing ['page'] will fix this.
Comment #15
jwilson3Comment #16
jwilson3Comment #18
thedavidmeister CreditAttribution: thedavidmeister commentedah, sorry. I missed all this! great that someone else is taking interest :)
I'm not sure about trying to make 'maintenance_page' work more like 'page' here. I think that's super great in theory, but should live as a separate issue under #2025629: [meta] Ensure that all #theme/#theme_wrappers hooks provided by core are associated with a sensible, re-usable element #type, especially if the newly proposed approach isn't coming back green.
I was hoping the scope of this issue would be as small as possible, as fixing it unblocks at least 4 other issues.
I've also discussed the approach that I took with @alexpott and @catch in IRC and got a preliminary "go ahead", AFAIK it's literally just waiting on some tests as at #6.
Comment #19
thedavidmeister CreditAttribution: thedavidmeister commentedI took the liberty of opening #2086619: #theme 'maintenance_page' should be based on #type 'page'.
Comment #20
thedavidmeister CreditAttribution: thedavidmeister commentedFWIW, I did manage to install Drupal with the patch in #15, so I'm resubmitting for testing. If it's actually green, then maybe we should keep going with that approach here.
Comment #21
thedavidmeister CreditAttribution: thedavidmeister commented#15: 2072647-15.patch queued for re-testing.
Comment #22
thedavidmeister CreditAttribution: thedavidmeister commentedoh green this time, yay! I'm working on tests.
Comment #23
jwilson3Saaaawweeeet!
Comment #24
thedavidmeister CreditAttribution: thedavidmeister commentedThis is not finished, the tests work but need some refactoring still.
Comment #25
thedavidmeister CreditAttribution: thedavidmeister commentedjust the failing test.
Comment #27
thedavidmeister CreditAttribution: thedavidmeister commentedgreat, things that pass locally but not on d.o...
Comment #28
thedavidmeister CreditAttribution: thedavidmeister commentedgreen?
Comment #29
thedavidmeister CreditAttribution: thedavidmeister commentedUses DOMDocument instead of regex
Comment #31
thedavidmeister CreditAttribution: thedavidmeister commented#29: 2072647-29.patch queued for re-testing.
Comment #33
thedavidmeister CreditAttribution: thedavidmeister commented#29: 2072647-29.patch queued for re-testing.
Comment #35
thedavidmeister CreditAttribution: thedavidmeister commentedsorry for the noise. getting different errors each time, and they don't show up on local.
Comment #36
thedavidmeister CreditAttribution: thedavidmeister commented#29: 2072647-29.patch queued for re-testing.
Comment #37
thedavidmeister CreditAttribution: thedavidmeister commentednicer test names.
Comment #38
tim.plunkettnew \DOMDocument();
String::checkPlain
Url::stripDangerousProtocols
Otherwise, I think this looks good!
Comment #39
thedavidmeister CreditAttribution: thedavidmeister commentedhere we go.
Comment #40
thedavidmeister CreditAttribution: thedavidmeister commentedI've opened:
- #2089327: Remove / deprecate calls to drupal_strip_dangerous_protocols() use \Drupal\Component\Utility\Url::stripDangerousProtocols()
- #2089331: [meta] Replace calls to check_plain() with Drupal\Component\Utility\String::checkPlain()
Comment #41
thedavidmeister CreditAttribution: thedavidmeister commentedunassigning from myself so someone can review
Comment #41.0
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #42
thedavidmeister CreditAttribution: thedavidmeister commentedRelated: #2088957: title in template_preprocess_maintaince_page should be on 'content' not 'page'
Currently, '#title' for 'page' does not work for maintenance pages. The functionality *looks* like it would work, but there's no way to pass 'page' into the preprocess in reality.
This could be fixed if 'content' was a render array that could have a #title attribute.
Comment #43
jibran$GLOBALS i don't like it. Do we have any alternative to this yet?
I think we can leave it as per #2089337: Decide if tests are allowed to use \Drupal::something() instead of $this->container->get()
We can use Xss::filterAdmin instead of filter_xss_admin.
This should be heredoc string.
Can we use here?
Comment #44
thedavidmeister CreditAttribution: thedavidmeister commented1. The only reason that $GLOBALS appears in this patch is because it's more inline with what template_preprocess_page() does. It looks like work on getting at the active theme without globals is happening still #1954892: Replace 'theme callback' and hook_custom_theme() with a clean theme negotiation system.
2. So, nothing to do here then?
3. sure. updated in patch.
4. also updated.
5. we need to use url() to keep the tests portable, or they won't always match the output of template_preprocess_maintenance_page()
Comment #45
thedavidmeister CreditAttribution: thedavidmeister commentedI opened #2089433: Remove uses of deprecated XSS filter functions
Comment #46
jibranThank you @thedavidmeister for fixes. Code looks great. It has tests now. Nice clean up. So RTBC.
Comment #47
webchickPatch no longer applies.
Comment #48
thedavidmeister CreditAttribution: thedavidmeister commentedreroll
Comment #50
thedavidmeister CreditAttribution: thedavidmeister commented#48: 2072647-48.patch queued for re-testing.
Comment #52
thedavidmeister CreditAttribution: thedavidmeister commented#48: 2072647-48.patch queued for re-testing.
Comment #53
jibranBack to RTBC.
Comment #54
alexpottPatch no longer applies.
Comment #55
LinL CreditAttribution: LinL commentedReroll
Comment #57
jwilson3that's odd that the patch failed the two tests it added.
Comment #58
thedavidmeister CreditAttribution: thedavidmeister commentedindeed, was the markup of the maintenance page changed recently?
Comment #59
herom CreditAttribution: herom commentedupdate patch.
@thedavidmeister, this happened: #2067915: Restore html attributes to maintenance-page.html.twig
Comment #60
jwilson3The interdiff looks fine, but the patch itself is unbelievable because it messes with a *ton* of unrelated stuff. You can tell just by comparing file sizes: it jumped from 7KB to 48KB between #55 and #59 :P
Comment #61
herom CreditAttribution: herom commentedoh! The patch wasn't rebased on HEAD, but diffed against HEAD.
fixing.
Comment #61.0
herom CreditAttribution: herom commentedUpdated issue summary.
Comment #61.1
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #62
thedavidmeister CreditAttribution: thedavidmeister commentedTagging for #2094585: [policy, no patch] Core review bonus.
Comment #62.0
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #62.1
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #63
star-szrTagging for reroll.
Comment #64
herom CreditAttribution: herom commentedrebased (auto-merged by git)
Comment #65
jwilson3Looks good to me. In addition to unblocking all the other render api cleanups, this is the ground work for fixing a long time theming wtf. Themers will finally have an easier time converting
page.(tpl.php|twig)
tomaintenance-page.(tpl.php|twig)
.My only thought is that we need better test coverage of drupal_add_region_content(), but I believe this test coverage doesnt necessarily block the changes here, and could be added as a part of #713462: Content added via drupal_add_region_content() is not added to pages.
Comment #66
herom CreditAttribution: herom commentedpatch didn't apply.
another reroll (again, auto-merged by git).
Comment #68
herom CreditAttribution: herom commentedComment #69
herom CreditAttribution: herom commentedthe order of loading css files was modified in #2008270: Remove drupal_add_css() from template_preprocess_maintenance_page() — use #attached.
system.theme.css
was given a higher weight than the rest (CSS_SKIN - 10
).Comment #70
ianthomas_uk69: 2072647-69.patch queued for re-testing.
Comment #71
ianthomas_ukCritical as this blocks #1830588: [META] remove drupal_set_title() and drupal_get_title()
Comment #73
herom CreditAttribution: herom commentedtwo things happened:
#2168113: Add leading underscore and other discouragement to drupal_add_css() and drupal_add_js(), #1862202: Objectify the language system
Comment #74
star-szrThanks @herom and @ianthomas_uk, I'm going to review this today.
Comment #75
star-szrLooks great!
Minor but moving $site_config up doesn't seem to have any purpose and IMO is harder to follow.
Since that change is so small, rolling it in here.
Nice, could this approach be taken with other render tests?
I'm also uploading a test-only patch again since it's been quite a while and we can't see the results of the last one.
Passing the core review bonus tag on to #1987398: field.module - Convert theme_ functions to Twig.
Comment #77
catchCommitted/pushed to 8.x, thanks!
Comment #78
thedavidmeister CreditAttribution: thedavidmeister commentedReally?
What is the hash for the commit that was pushed? I just fetched/pulled and I can't see any of the changes from #75.
Comment #79
catchYes you're right, that was imaginary apparently.
Now properly committed/pushed to 8.x.
Comment #80
thedavidmeister CreditAttribution: thedavidmeister commentedThanks!
Comment #82
sunNote that I'm removing the code and the test coverage in #2218039: Render the maintenance/install page like any other HTML page