Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
theme system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Jan 2013 at 21:02 UTC
Updated:
25 Aug 2015 at 22:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #0.0
jenlamptonadded changes
Comment #1
jenlamptonThere is some weirdness in this patch that works - but maybe there's a better way to do these things (feedback appreciated):
- in theme.inc,
drupal_common_theme, I had to add a bunch of'preprocess functions'definitions to get the preprocess functions to run for these new higher-level bootstrap templates.- in theme.maintenance.inc both
template_preprocess_install_pageandtemplate_preprocess_update_pageI needed to change the template file called to maintenance-page, and did so by setting$variables['theme_hook_original'].Comment #2.0
(not verified) commentedrelated
Comment #3
jenlamptonokay, I may be out of my depth a bit here. I was able to get these changes working in our sandbox to confirm that the twig templates are rendering correctly, but I may not know how to apply these changes directly to core. I could use some help :)
Here's how I got these working in our sandbox:
1) changed the maintenance theme in settings.php to stark.
2) changed stark to use twig as it's theme engine.
3a) add the template files into the stark theme.
3b) update theme.inc to include new information about preprocess functions
3c) replace the theme functions in theme.maintenance.inc with preprocess functions
Visit the installer, confirm that stark is the theme being used.
Change the twig templates to confirm that they are being rendered.
Everything works.
So now for core...
1) I assume I don't need to change the maintenance theme, we want this to work with seven (?)
2) I assume I dont have to change seven to use twig as the engine, twig templates should work anyway (?)
3a) add the template files into the system module since this is where we actually want them
3b) update theme.inc to include new information about preprocess functions
3c) replace the theme functions in theme.maintenance.inc with preprocess functions
Visit the installer, utter fail.
Attached patch should still fail because of my confusion about the above, but fixes a missing use Attribute line.
Comment #4.0
(not verified) commentedrelated
Comment #4.1
jenlamptonclean up
Comment #5
c4rl commentedMore general title. Updated summary.
Comment #6
koppie commentedI've got a couple questions about your patch. Sorry these questions are so newb-level, just trying to help.
I've created a diagram that describes the function changes in this patch: https://docs.google.com/drawings/d/1YSwbiZr_zNN8NzU8xrci4UfMXRZve_bpM_sZ...
Comment #7
mbrett5062 commented@jenlampton, here is your problem I think, well at least part of it :).
$item_listsshould be$item_list.Plus, have you declared
$listsas an empty array before populating it, I do not see it.Comment #8
star-szrComment #9
star-szrMade some progress, but in my working copy template_preprocess_update_page() and template_preprocess_install_page() are not being called. Tomorrow I'll post a patch that should at least install.
Comment #10
star-szrI used base_hook to make update.php and install.php work on HEAD, but as mentioned in #9, template_preprocess_update_page() and template_preprocess_install_page() are not being called. I couldn't figure out a way to get the preprocess to fire. I tried adding them to 'preprocess functions' in drupal_common_theme() (along with the base_hook), but that seems unnecessary and didn't change anything anyway.
See also:
#1885714: Remove theme_install_page()
#1885850: Remove theme_update_page()
The 'theme_hook_original' approach taken in the sandbox (#1821006-3: Create preprocess function for theme_install_page) doesn't seem to work on HEAD (the patch in #3 here results in a blank screen for both install.php and update.php), and I'm not even sure how it works on the sandbox, grepping through core I can only see theme_hook_original being stored, not used in any way.
Comment #11
star-szrAlso, 'show_messages' => NULL was added to install_page in drupal_common_theme() to prevent these errors after installation:
Notice: Undefined index: show_messages in template_preprocess_maintenance_page() (line 3048 of core/includes/theme.inc).Comment #12
star-szrFrom #10:
Not strictly true, but the only place I saw it being used was in template_preprocess_item_list(), which I don't think applies here.
Comment #14
star-szrTurns out installation was only working locally because I already had a settings.php file.
After talking to @Fabianx, it sounds like theme.maintenance.inc will actually need to be converted in stages.
engine = twigin .info file or make Twig the default theme engine.So here's a more modest patch that just does #1 in preparation for the next steps.
Comment #15
star-szr#2 and #3 from my comment in #14 would probably need to be in the same patch.
Comment #16
c4rl commentedBased on #1905584: Move base theme system templates into /core/templates it seems this issue would be accommodated by #1898454: system.module - Convert PHPTemplate templates to Twig, though that may result in a large patch.
Comment #17
c4rl commentedIgnore what I said about system.module in #16, we'll proceed to convert this separately of system.module and put in /core/templates as described in #1905584: Move base theme system templates into /core/templates
Comment #18
star-szrRe-posting patch from #10 (freshly rerolled to remove the offset) now that #1942490: Make Twig engine available during install is in!
Comment #19
star-szrDocs will need some love (#1913208: [policy] Standardize template preprocess function documentation for instance), will take a look over the next few days.
Comment #20
star-szrAfter looking at this again, I think #1885850: Remove theme_update_page() and #1885714: Remove theme_install_page() should just be incorporated into this issue, unless someone can figure out how to get those preprocess functions (template_preprocess_install_page, template_preprocess_update_page) to fire. I know we're trying to just convert and not consolidate yet, but I think this might be a good case for an exception to be made.
Edited for clarification.
Comment #21
star-szrDoing #20 would introduce its own problems, see #1885714-2: Remove theme_install_page(). So I'm instead proposing that for this initial conversion issue, we actually don't touch theme_update_page() or theme_install_page().
Attached patch does this, cleans up docs, and also moves the parens around "active" and "done" from template_preprocess_task_list() to task-list.html.twig.
Comment #22
star-szrNope, that's not the right patch. Try this one, interdiff is from #18.
Comment #23
star-szrSorry for the patch onslaught. Revised the patch with more docs touchups and converted the remaining theme() calls to render arrays. Interdiff is from #22.
Comment #23.0
star-szrImprove summary
Comment #24
star-szrLooks like maintenance-page.tpl.php conversion should be part of this patch.
Comment #24.0
star-szrNote status of theme_install_page() and theme_update_page().
Comment #24.1
star-szrAdd conversion summary table
Comment #25
star-szrAdded maintenance-page.html.twig from the sandbox and made a few minor tweaks. See #1189822: Convert maintenance-page.html.twig to HTML5 to convert maintenance-page to HTML5, this is just a straight conversion so yes it's XHTML and that's just fine for now :) Compared markup with Stark as the default theme and everything seems to match up.
This also fixes task-list. I'm not sure why, but the preprocess function was not firing without adding
'preprocess functions' => array('template_preprocess_task_list'),- copped from the sandbox.Comment #25.0
star-szrAdd maintenance-page.tpl.php HTML5 conversion issue to related
Comment #26
star-szrTagging. If anyone knows how we can manually test authorize.php please add testing steps in the summary.
Comment #26.0
star-szrUpdate conversion table, add testing steps
Comment #27
star-szrUnassigning for now, if I can figure out how to test the authorize.php report I'll post my findings and update the issue summary. Otherwise, this is ready for review.
Comment #27.0
star-szrremove sandbox
Comment #27.1
star-szrUpdate conversion table
Comment #28
c4rl commentedPer #1757550-44: [Meta] Convert core theme functions to Twig templates, retitling to indicate this issue applies to theme_ functions rather than templates. See #1987426: Convert maintenance-page.tpl.php to Twig for template conversion.
Comment #28.0
c4rl commentedAnother tweak
Comment #28.1
c4rl commentedUpdated issue summary.
Comment #29
shanethehat commentedComment #30
intergalactic overlords commented#29: twig-maintainence-page-theme-only-1885564-29.patch queued for re-testing.
Comment #32
socketwench commented#29: twig-maintainence-page-theme-only-1885564-29.patch queued for re-testing.
Comment #34
hanpersand commented#29: twig-maintainence-page-theme-only-1885564-29.patch queued for re-testing.
Comment #36
socketwench commentedReroll!
Comment #38
damienmckenna#36: twig-maintainence-page-theme-only-1885564-36.patch queued for re-testing.
Comment #39
johnshortessManually testing this now...
Comment #40
aspilicious commentedMaybe newbies question but why do you need to set the preprocess function for task_list but not for authorize_report?
Comment #42
johnshortessI'm not 100% sure I found all use-cases that get routed through authorize.php, but for everything I tested, the markup using Twig and the patch in #36 was identical to the markup from PHPTemplate.
Comment #43
star-szrRe #40, I don't see why we would need to specify the preprocess functions, so I think that can be removed.
Comment #44
drupalninja99 commentedI removed the preprocess function line.
Comment #46
drupalninja99 commentedGetting "Fatal error: Class 'Attribute' not found in /Applications/MAMP/htdocs/drupal8/core/includes/theme.maintenance.inc on line 131" from template_preprocess_task_list(). I need to figure out how to load the Attribute class.
Comment #47
drupalninja99 commentedOk I found the issue, I added "use Drupal\Core\Template\Attribute;" to theme.maintenance.inc and that fixed the /install.php problem
Comment #48
drupalninja99 commentedComment #50
drupalninja99 commented#47: twig-maintainence-page-theme-only-1885564-47.patch queued for re-testing.
Comment #51
star-szrThanks everyone for working on this one! Tagging for profiling.
Comment #52
thedavidmeister commentedmanual testing is a novice task.
Comment #53
star-szrNeeds a reroll before it can be tested or profiled.
Comment #54
joelpittetCleaned up a bit and re-rolled.
Comment #56
joelpittet#54: 1885564-54-twig-theme-maintenance.patch queued for re-testing.
Comment #58
joelpittet#54: 1885564-54-twig-theme-maintenance.patch queued for re-testing.
Comment #60
joelpittetSeems there was a bunch of things not so right so here is an attempt to correct them.
Comment #61
star-szrNeeds a rebase just based on the patch file size. Thanks for working on this :)
Comment #62
joelpittetWhoops
Comment #63
royko_at_duo commentedComment #64
royko_at_duo commentedUnassigning for now, but will try to take another look when possible. Couldn't figure out how to manually test authorize.php (same as #27). Any ideas? Please post thoughts...
Comment #65
royko_at_duo commentedAfter installing this patch, I reviewed the update routine where these messages would appear (task list) and found everything in order. I also tested the same code on a new install (fresh DB) and reviewed task list on install. Worked. I 'm still not entirely sure how to conclusively test the authorize message template, but reviewed the code. I don't think there's any issue here -- looks clean. so... marking as reviewed.
Comment #66
catchThis really needs testing of authorize.php as well before it can be committed.
In addition it'd be good to test what happens when the database is down etc. since presumably these will be called then too.
Comment #67
star-szrYes, this needs more testing as well as profiling. To start we could manually invoke authorize_report with some data and check before/after output (and perhaps profile that way as well), until we can figure out how to test authorize.php properly.
Comment #68
catchI'm not worried about profiling - performance of the maintenance page isn't a big deal, but definitely additional testing.
Comment #69
star-szrOkay, great. Thanks @catch!
Any hints as to how we can test authorize.php in a realistic scenario? So far we've had a few people try (myself included) and come up short, and I asked in #drupal-contribute a few times but to no avail.
Comment #70
cosmicdreams commentedWow, a question from August, and I think I know the answer.
From my experience with manually testing Drupal 7, I remember I came across errors with the authorize.php (remember when this always blew up early in D7?) whenever you used the system's "install a new module" feature from the modules (now, extend) page.
Comment #71
star-szrI am having trouble testing that 'Install a new module' functionality, possibly related to PHP 5.4 and this issue:
#842620: Update manager can't install modules using FTP due broken FileTransferAuthorizeForm
Comment #71.0
star-szrUpdated issue summary.
Comment #72
joelpittet62: 1885564-62-twig-theme-maintenance.patch queued for re-testing.
Comment #74
joelpittetTwo things are bothering me a bit with authorize-message.html.twig:
If anybody knows how to test those pages. please let us know.
Comment #75
joelpittetKilled the theme_authorize_message because it wasn't a theme function, it was just a helper to build array items for an item_list.
Tested the output of the 'authorize_report' manually with a direct call to the theme function because I couldn't find a way to get at it otherwise.
Comment #76
star-szrComment #77
star-szrComment #78
star-szrTagging for reroll.
Comment #79
longwaveRerolled.
This ID doesn't seem to be referenced anywhere else.
I agree that this should probably be done with CSS instead.
Comment #80
joelpittetThis is where authorize-results should show up during markup review.
We may have to do the .failure CSS change in a follow-up issue but maybe Cottser can weigh in on that?
Comment #81
star-szrIf it's a markup change I'd lean towards follow-up, probably better if these conversions don't touch CSS.
Comment #82
joelpittetHere's a quick dreammarkup followup for that:
#2215543: Replace strong tag with CSS in template_preprocess_authorize_report and remove id..
Comment #83
longwaveI meant that #authorize-results doesn't seem to be referenced from CSS or JavaScript, so if it's unused maybe we should consider dropping it from the output markup entirely (and if that's the case we can perhaps remove the wrapper <div> as well?)
Comment #84
joelpittetOh ok now I understand, feel free to add that to the dreammarkup issue in #82 as well.
Comment #85
aboros commentedThe patch in #79 did not apply.
Here is a re-roll of it.
Comment #87
star-szr85: 1885564-twig-theme_maintenance-85.patch queued for re-testing.
Comment #88
star-szrTagging for reroll.
Comment #89
trevorkjorlien commentedAssigning to myself. Assigned during my first Core Mentoring session.
Please be kind!
Comment #90
trevorkjorlien commentedChanged
use Drupal\Component\Utility\Settings;touse Drupal\Core\Site\Settings;.Settings moved in this issue: #2208475: Move Settings into Drupal\Core\Site\Settings
Comment #92
trevorkjorlien commented90: 1885564-twig-theme_maintenance-90.patch queued for re-testing.
Comment #93
vollepeer commentedGuys, we can't proceed work on https://drupal.org/node/2215543 because of this issue. Thanks!
Comment #94
joelpittet@vollepeer that issue just makes a small CSS issue that's why it was broken out. This issue can proceed it needs manual review to make sure the markup is the same before and after.
The only thing that may be holding this back is we aren't sure how to view those autorized pages, and if you know that or could find that out we can get some people to test the markup hasn't changed.
Comment #95
SebCorbin commentedWrong class change here from "visually-hidden" to old "element-invisible"
Same thing here
Note that authorized_result was unusable before this due to the use of theme_authorize_message(). The markup is OK now that it is removed
Patch attached
Comment #96
SebCorbin commentedJust resetting the status to get the patch tested
Comment #97
SebCorbin commented.twig files were missing
Comment #99
lewisnymanAre the needs tags here still relevant?
Comment #100
joelpittetYes they are we, still need a markup comparison (needs manual testing tag) of the authorize report and we aren't sure how to get that template for the "steps to test".
Comment #101
lauriii97: 1885564-twig-theme_maintenance-98.patch queued for re-testing.
Comment #102
steinmb commentedI could take this for a spin but I'm missing the steps of how and where to test.
Comment #103
star-szrYes, we apparently have authorize.php in core but nobody knows how to manually test it or they're not telling :( See around #66 #69 comments.
Comment #104
mbrett5062 commentedI wonder if this helps with manual testing, the following is from settings.php
So to test, login to an account that is not the maintenance account, but has permission "Administer software
* updates" then access update page that should give positive result, and without permission should give negative.
Then try with site maintenance account, should give positive result.
Then try login with account with no "Administer software
* updates" permission, should give negative result, and finally edit settings.php
$settings['update_free_access'] = FALSE;Change to "TRUE" and try again, should give positive result.
Hope that makes some kind of sense.
PS the page to try is "yoursite/update.php" plus, also try last step as anonymous user, should give same results with settings.php change from FALSE to TRUE
Comment #105
star-szr@mbrett5062 sure but that's update.php, we need to test authorize.php.
Comment #106
mbrett5062 commentedBut I thought that is all authorize.php does, is authorize the use of update.php for various scenarios. So if the tests I outlined pass or fail that is an indication the authorize.php is working correctly. Or do you need more direct testing. Maybe I misunderstand the use of authorize.php, if so please forgive my noise.
Comment #107
star-szr@mbrett5062 - I honestly don't know because I've never used authorize.php and from the sounds of it a lot of folks haven't. Thanks for your efforts :)
Comment #108
mbrett5062 commentedThe way I understand it, and have only once had to make use of authorize.php is in the following scenario.
A module is updated, but contains broken code, that kills your site, not allowing you to reach even the login page or the front end.
A new release of the module is created that will fix the bug and revert any bad database changes, but you can not access the site as admin to run update.php.
So you edit settings.php and then are able to run update.php as anonymous user. Fixing the bug and database so resurrecting your site.
Comment #109
mbrett5062 commentedTested manually on new download of D8-dev. With and Without patch works as expected, output looks exactly the same. Attached file is a diff of the full page HTML output.
(Not that it shows much as there is no difference)
Oppss did not realize .diff would be sent for test, sorry.
Comment #111
joelpittet@mbrett5062 No worries about the .diff patch fail. *.txt works well or something-do-not-test.patch I think also works.
A diff for manual testing would be if you could turn on twig_debug config setting in your settings.php and the before and after the patch you should see a reference to
authorize-report.html.twigin the twig debug message.twig_debug is in the settings.local.php so you can just copy and uncomment that into your settings.php. After a cache rebuild (drush cr) you will see all the twig templates rendered on the page in html comments.
Comment #112
star-szrRe: #108:
It's my understanding that this is not the same thing as authorize.php. The docblock in authorize.php starts with "Administrative script for running authorized file operations."
Comment #113
SebCorbin commentedauthorize.phpis called when manipulating files from the interface.Right now there is a bug preventing that #2042447: Install a module user interface does not install modules (or themes)
Comment #114
SebCorbin commentedOK so after solving #2042447: Install a module user interface does not install modules (or themes) I've encountered the fact that preprocess functions (i.e.
template_preprocess_*) were not automatically discovered.So I attached a patch and the whole thing is testable with simplytest.me
To test:
Comment #115
SebCorbin commentedOk so I investigated why the preprocess functions would not be discovered from time to time. It's because they reside in theme.maintenance.inc and this file is included on demand by
drupal_maintenance_theme()(whereas pager.inc is always included for example). So it depends when the Theme Registry is built.As a solution: either we state the preprocess functions, either we add the path (relative to the system module) in
drupal_common_theme().This patch is testable with simplytest.me too with the same process as before
D8 maintainer will have to chose either #114 or this one
Comment #116
star-szrThanks @SebCorbin! Overall I like the 'file' a lot better (#115) but not the ../../../ part. Can we use DRUPAL_ROOT or a PHP built-in to handle that?
Comment #117
SebCorbin commentedWell the path is relative to the system module, so we can do
Comment #118
joelpittetRe-rolled.
__DIR__ could work too, it's built into pHP and you are already in the includes folder. So the file could literally be the file.
Though a bit confused why this is needed... shouldn't it just pickup in the current directory by default?
And, I'm considering moving the authorize theme functions into their own issue so we can get the task list one in. And deal with those two on their own with a fresh start(of not knowing how to test). :P
Comment #119
joelpittetSplit out task_list because that is ready to go in and we need to get the steps to reproduce for the authorize templates.
#2329505: Convert theme_task_list to Twig template
Tried the thing above with __DIR__ but not sure if the 'path' relates to the 'file' or the 'template' or both...
Comment #120
joelpittetComment #121
joelpittetThat __DIR__ doesn't work after I looked at how it works... and 'path' get's applied to the template and the file...
includes works best I think, I tested it out on our testable version for the task-list.html.twig and it worked for the preprocess firing and the template loading.
Comment #123
joelpittet@SebCorbin you rock!!! That patch of yours in #2042447: Install a module user interface does not install modules (or themes) totally makes this testable.
Comment #124
star-szrI totally missed the testing steps somehow, thanks @SebCorbin I've added those steps to the issue summary! You do indeed rock.
Comment #125
star-szrThanks again @SebCorbin, you have no idea how good it feels to finally see authorize.php after waiting for well over a year :)
I tested the latest patch here along with #2042447-27: Install a module user interface does not install modules (or themes) and I tested installing http://ftp.drupal.org/files/projects/page_manager-8.x-1.x-dev.tar.gz. This patch isn't 100% but it's a heck of a lot better than what's happening on HEAD.
Also not sure about the page_manager section in the before (if it's even supposed to be there…), we are losing that with this patch.
Before patching
After patching
Comment #127
star-szrOops, I forgot to change the issue # for the suggested commit message on #2329505: Convert theme_task_list to Twig template. Don't worry, nothing from here got committed :)
Comment #129
lauriiiDid small reroll for this
Comment #130
lauriiiHere's few screenshots from the page
Comment #131
rainbowarrayWrong issue, laurii?
Comment #132
star-szrRight issue, see the last handful of comments.
Comment #133
akalata commentedDid a reroll, but can't test this; attempting to install new modules (even with the latest from #2042447: Install a module user interface does not install modules (or themes)) doesn't work.
Comment #134
joelpittetThank you for the re-roll @akalata
I was reviewing this and noticed this:

I used the latest patch from #2042447: Install a module user interface does not install modules (or themes) to review.
Comment #135
joelpittetI'm a bit baffled why that would escape, they are renderable arrays with #markup... I may need to take another stab at this to move more markup to the template.
Comment #136
devin carlson commentedReroll of #133.
Comment #137
devin carlson commentedComment #138
devin carlson commentedComment #139
joelpittetRe-rolling for the markup/class changes.
Comment #140
joelpittetI think this is an array sometimes and possibly just need to cast it as always being that and just add '#wrapper_attributes' to it, but not sure yet... need to debug and step through this.
Comment #141
joelpittetThe escaping is because after the batch process all the SafeMarkup set's are gone. Need to somehow peel them out of batch, or set them as safe after. The later being easier.
Comment #142
SebCorbin commentedSolved 2 issues:
Patch from https://www.drupal.org/node/2042447#comment-9623965 still required
Comment #143
SebCorbin commentedHere's the current result and what we aim to obtain
Comment #144
joelpittet@SebCorbin thanks, could you post an interdiff so we can see exactly your changes please? https://drupal.org/documentation/git/interdiff
#markup is a bit cheating but I'm not sure how else we can deal with it through the batch process it seems to lose being safe markup. A bit worried about the need for $GLOBALS['base_url'] now, there should be a way to avoid the need for that, no?
Comment #145
SebCorbin commentedSorry, here's the interdiff (and the twig file was missing too).
Either we use #markup, or we change the
$content['next_steps']to be integrated with$content['authorize_report'].About the
$GLOBALS['base_url'], I know it's a bit dirty, but I think it's cleanier than usingfromUri('base:../admin/modules')to get out of the parentcore/directory.Install script is using it too, as it's also in the core/ directory http://cgit.drupalcode.org/drupal/tree/core/lib/Drupal/Core/Installer/Ex...
Comment #146
joelpittetThanks for the interdiff, let's sort that base_url stuff out in a different issue as it's unrelated to this and seems like a more fundamental problem. You have some include stuff added to the registry snuck into that patch as well, that should be removed.
Comment #147
rteijeiro commentedFixed @joelpittet suggestions in #146
Comment #148
akalata commentedWhen testing, should I apply the latest patch here, or the latest patch from #2042447: Install a module user interface does not install modules (or themes) first? Both apply cleanly on their own, but not when taken together.
Comment #150
mpdonadioPer the manual testing instructions, this needs to be rerolled b/c the two patches no longer apply together. Postponing until #2042447: Install a module user interface does not install modules (or themes) is in (it is currently RTBC). Also triggered a retest to see if the current patch still works.
Comment #151
joelpittetNeeds both for manual testing properly. Rerolled`
Comment #152
joelpittetThere was some unnecessary changes in the re-roll and moved report variable that the template expected to the definition and made use of the attributes object that was added.
Comment #155
SebCorbin commentedRerolled
Comment #156
SebCorbin commentedWrong patch rerolled, there shouldn't be:
Anyway after manual testing, the "Next steps" links are always escaped, I will work on it
Comment #158
SebCorbin commentedAgain, I see no other way of handling
$GLOBALS['base_url'], as in authorize.php, it is wrongly initialized in the Url generator.In core/install.php, the same applies, and they directly use
global $base_url;So either we pass the correct absolute url from the batch result, or we initialize like it is done in core install.
Suggestions are welcome.
Comment #160
mpdonadioIf you are explicitly setting the base_url, should there be a test to ensure that the right link paths are being generated or is there already coverage for these?
I'm going to try to look at the base_url thing in general tonight.
Comment #161
mpdonadioOK, spoke for a while with @dawehner about this on IRC. Here is a comment that addresses the base_url usage. Didn't look at the fail.
We also agree that there needs to be test coverage on the links that generates to make sure they are correct.
I'm going to create an issue to address this, as having to use the global like this is just wrong, but unavoidable. It also happens in a few places in core.
Comment #162
mpdonadioWouldn't call this a true followup, but created this, #2548095: Add option to Url() to force the site base_url to be used. The final version of the patch should probably reference this as a @todo so we can track the places we need to fix.
Comment #164
mpdonadioJust added the @todo for #2548095: Add option to Url() to force the site base_url to be used.
Comment #166
David_Rothstein commentedI agree with #2548095: Add option to Url() to force the site base_url to be used (the current behavior seems pretty nutty) but shouldn't we be dealing with the workaround in #2547667: Fix broken page title Update Manager (authorize.php) rather than this issue?
I'm going to take a quick look at the failing test...
Comment #167
mpdonadio#166, I didn't remember about that issue. It turns out to be a systemic problem, as #2540416: Move update.php back to a front controller currently has a similar hack, and would pop up again if we and another front controller (not sure why we would, but it's possible). So, it may be best to track base_url thing as a separate issue.
Comment #168
David_Rothstein commentedThis took longer to figure out than it should have, but it looks like the code removed in #152 is still needed. (Without that, the preprocess function was not being called at all.) In addition to adding that back, I also reverted the change to the "report" variable from that patch as I think it is intended for the template only, not something the caller should pass in. This should pass tests now.
On the topic of the URLs, I now sort of see see why it's in this patch. Previously the double-escaping was fixed automatically by the rest of the code added in this issue, but now it requires changes to the URL generation too (I guess something must have changed with the SafeMarkup system in the meantime). So this is now touching the same code that #2547667: Fix broken page title Update Manager (authorize.php) would need to touch and it may therefore make sense to fix them both at once after all - in which issue, I'm not sure :) Whichever issue we fix it in should fix the theme installation links too, though (not just the module installation links), but I haven't done that here.
Comment #169
joelpittetThe hook_theme definition acts as a contract that the template knows what variables to expect. The caller doesn't have to pass those variables in, but the template needs to have some assurance that it will be getting that variable passed in. That is why I did that.
Comment #170
joelpittetThank you very much @David_Rothstein for tracking down that test fail, that sounds like a tricky one, I wonder when that changed(if it did).
For context on why those links need to be changed. They get built up as links in the batch, but on the next request the list which was in SafeMarkup::safe_strings is lost. I thought we solved this some time ago, but I guess not. Regardlress, nice fix changing them to render arrays, because that side steps the early rendering of the links and lets the safety be dealt with on render instead of before.
I'm just going to clean up with removing the array value indenting. We don't do that normally for coding standards(even though I've spotted a bunch in core).
https://www.drupal.org/coding-standards#operators
https://www.drupal.org/coding-standards#array
Comment #171
joelpittetI was testing things out and we missed the update task links converted to attribute links. Add those into the mix.
Will post manual testing screenshots next. Gotta do a bit of research how to fake batch + installer to authorize test...
Comment #172
joelpittetWhoops missing use statement for Url.
Comment #173
joelpittetManual Testing:
Install:

Update:

Comment #174
joelpittetThat "Run database updates" link needs that base URL thing *facepalm* I bet the other two links in there need that too, but not sure how to manually test that, any ideas?
I lucked out because have an older version of devel laying about to upgrade. But to test that you can just change the version number in the
.info.ymland remember to enable the module (or go to the settings and enabled checking of disabled moduleshttp://d8.dev/admin/reports/updates/settings)Comment #175
David_Rothstein commentedFixed those in the attached (I didn't come up with a way to test them manually except by hacking the code in authorize.php to force them to appear).
I also fixed the theme installation links, as mentioned in my earlier comment.
Finally, I wrote an automated test for the module installation links (one of the links, at any rate). Automated tests for module update links and theme installation/update links would be possible after #2548511: Write tests for the Update Manager downloading and applying updates for a module and #2548519: Extend Update Manager tests to handle installing/updating themes in addition to modules, respectively.
Hm, I see the point, but don't some templates have tons and tons of variables? I don't believe this is something we've ever enforced before, and it has the side effect of allowing/encouraging people to pass them in when they're not supposed to. (I think of hook_theme() more as a contract for code which is building up data and passing it in to the rendering system, personally.)
However would a simple way to make everyone happy be to just get rid of the 'report' variable entirely? I'm not sure it's necessary - messages get passed in and the template needs messages. The 'messages' variable could just be restructured by the preprocess function to be what the template expects.
Comment #176
David_Rothstein commentedLike this, I mean.
Comment #178
joelpittetYes that would make me happy:) was thinking similar thing.
Will review changes in the morning thanks for hack fixing those!
Comment #179
joelpittetIt also acts as default values for those templates with many variables(or they end up being dumped into 'render element' when things wild. Which are well/sane starting points that the template can fallback on which is making those variables optional. A real interface would really help this (D9). FYI, I've been pitching that "Define(hook_theme) what the template is expecting, build (render array), theme/markup(template)" in our hook_theme to twig template theme system talks. I could be wrong, but it's likely nobody paid attention to my blatherings:P. The render array building frequently skips variables: take
item_listfor example, thetitleandtypekeys are usually skipped as 90% of the time you are just spitting out aULlist.I'd RTBC this, but I think we should get another set of eyes on the matter. Thanks for the fixes they look great to me.
@mpdonadio Any thoughts on further automated tests since you tagged it?
Comment #180
mpdonadioThis doesn't really test that the link is correct, just that is a valid page. Maybe
$this->assertLinkByHref(Url::fromRoute('update.module_install')->toString());
$this->clickLink(t('Install another module'));
$this->assertResponse(200);
would be better? I'll post a patch later tonight if I have time (not on dev machine right now).
Comment #181
mpdonadioThese test changes work locally for me, and think they will be good in the long run and prevent any regressions involving fixing the base_url @todo.
Also changed uses of `new Url()` in the patch to `Url::fromRoute()`, which is the preferred usage per the docblock on Url::__construct().
Comment #183
joelpittetRTBC++, thanks for the test coverage @mpdonadio!
I'll find someone to do one last look through/test and hopefully RTBC.
Comment #184
mpdonadioJust updating the comment above the new assertions to reflect what they do.
Comment #185
akalata commentedLooks good here!
It took me a minute to figure out why these changes to Registry.php were needed; they were added in #145, suggested to be removed in #146, and added back in #168 when it was realized that they were actually necessary.
I tested both locally and on simpletest.me following the manual testing steps. Errors were successfully reported both times (different errors, was unable to get a success), visual result and HTML is identical to HEAD.
Comment #186
joelpittet@SebCorbin Sorry I didn't realize you fixed a few of these things before! Back in February before all that crazy url stuff even happened(I think you may be able to predict the future and will bring you to the track next time I meet you)
Comment #187
David_Rothstein commentedI'm on board with the new tests, but not with removing the previous ones. The main reason is that assertLinkByHref() does partial link matching, so if you ask it to find "admin/modules" but in fact "admin/modules/install" is the only link on the page, it will return TRUE even though the link you're looking for isn't there. So it's a little fragile to rely on that alone. It's fine to have them and is a good way to check multiple links, but I just think we should keep the clickLink() + assertResponse() for that one link also, as it actually ensures that the link takes you somewhere on the site.
(For what it's worth, we could add a $this->assertUrl('admin/modules/install') after clicking, and then we'd also be checking that it took you to the expected location... that is probably worth doing.)
I don't have time to do a patch right now, but should be a pretty easy change to get this back to RTBC.
Comment #188
joelpittet@David_Rothstein I agree, here's the patch to add it back.
Comment #189
joelpittetWithout the redundancy.
Comment #190
akalata commentedConfirming #189 addresses concerns from #187.
Comment #191
joelpittetChanging to a bug report because our tests prove as much in #181 and adding beta evaluation.
Comment #192
joelpittetComment #194
webchickAwesome, thanks a lot for this. This addresses some pretty big user-facing bugs in Update Manager (yay for expanded test coverage).
Overall this looks like some great consolidation from the theming side. I'm very sad about hunks like this:
...as you now need to write like 10 lines of PHP to make a link. :( But that wasn't invented here. Thanks for spinning off the follow-up issue to look into how to make links like this a bit fewer lines of code from now on. :)
No complaints here!
Committed and pushed to 8.0.x. YEAH!