Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Task
Convert system.module theme_ functions to Twig templates.
Remaining
- #2151123: Remove theme_system_modules_incompatible()
- #2151821: Convert theme_system_config_form() to Twig
- #2151097: Convert theme_confirm_form() to Twig
- #2151109: Convert theme_system_modules_details() to Twig
- #2151093: Convert theme_admin_block_content() to Twig
- #2151101: Convert theme_status_report() to Twig
- #2151113: Convert theme_system_modules_uninstall() to Twig
- #2151117: Remove theme_system_powered_by()
- #2151089: Convert theme_admin_block() to Twig
- #2151095: Convert theme_admin_page() to Twig
- #2151105: Convert theme_system_admin_index() to Twig
- #2151107: Convert theme_system_compact_link() to Twig
- #2151119: Convert theme_system_themes_page() to Twig
Comment | File | Size | Author |
---|
Comments
Comment #0.0
star-szrUpdated issue summary.
Comment #1
c4rl CreditAttribution: 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 #1898454: system.module - Convert PHPTemplate templates to Twig for template conversion.
Comment #1.0
c4rl CreditAttribution: c4rl commentedUpdated issue summary.
Comment #2
gnugetPatch attached
Comment #3
minneapolisdan CreditAttribution: minneapolisdan commented#2: system_theme_functions_to_Twig-1987410-1.patch queued for re-testing.
Comment #5
gnugetThis patchs needs a re-roll i guess... i'm going to work on it.
Comment #6
gnugetHere a rerolled version.
Comment #7
joelpittetThanks @gnuget.
Here is a few nitpiks.
Array shouldn't be in the description, change to 'A list'
Indenting on this should be in line with other twig indentation.
@see http://twig.sensiolabs.org/doc/coding_standards.html
These sub items should be indented without the name.
ie.
- attributes
not group.attributes.
@see https://drupal.org/node/1823416
Comment #8
IshaDakota CreditAttribution: IshaDakota commentedRe-roll and nitpicks from #7
interdiff from after re-roll.
Comment #10
IshaDakota CreditAttribution: IshaDakota commentedbotched that re-roll. Attached re-roll only to test before adding the "nitpicks."
Comment #11
IshaDakota CreditAttribution: IshaDakota commentedwith patch :)
Comment #12
joelpittetThank you @IshaDakota:)
FYI, there is a bunch more nitpicks and performance improvements on this patch as it's fairly big. Mostly to do with attributes but I'll wait till the patch turns green before I write them up.
Comment #13
IshaDakota CreditAttribution: IshaDakota commentedOK @joelpittet - I'll wait for a write up before submitting a new patch.
Comment #14
joelpittetOk here they come:) @IshaDakota if you have any questions I should be around on IRC (#drupal-twig) if you have any questions or leave the questions here.
This is a task in itself but we don't need to instantiate Attribute for anything in this patch because they should all be lazy loaded through #1982024: Lazy-load Attribute objects later in the rendering process only if needed
This would mean removing all the new Attribute() calls form this patch and leaving them as arrays.
None of the variables in system_theme() need to be converted to an empty array from NULL. I have a good feeling that was a twig bug that was fixed here: #1975462: Allow and test for NULL and integer 0 values in Twig templates.
if this is an empty preprocess function, it can be deleted.
dl needs one more indent.
contents of if block nees one more indent and if statements shouldn't be on oneline.
80 charachters and 'An array of' should be 'A list of'.
the indent and formatting of the requirements properties is incorrect. @see https://drupal.org/node/1823416
Remove the todo, the issue should be good enough. We can't commit with @todos.
Capital F for the sentence.
The main item 'group' and 'theme' and all their sub items need to be formatted according to the twig standards here: https://drupal.org/node/1823416
Comment #15
IshaDakota CreditAttribution: IshaDakota commentedComment #16
IshaDakota CreditAttribution: IshaDakota commentedOK, I think maybe I got everything from #7 and #14, thanks to @joelpittet in IRC.
Comment #18
joelpittetThank you @IshaDakota!
There is still quite a bit to do on this patch as I skimmed through so we need a fresh pair of eyes I bet.
I was wrong on some of those array() to NULL. Here's a patch that inches this a bit further.
Comment #21
joelpittetOk @IshaDakota! I was a little heavy handed on the Attributes note but it's still much better (even though it's red:)
This may still not pass, but again, I promise it's in the correct direction.
So the Attributes here that I had to leave in as Attribute objects are not $variables['attributes'] that you changed to arrays. Those ones are cool, and also not $whatever['#attributes'] which is a renderable array that will get themed. It's only the ones that are $whatever['attributes]. It's subtle, confusing and important:)
@IshaDakota, checkout how I cleaned up the twig files with those |keys nonesense and split out attributes.class. There are a number of other templates that need the same cleanup. And whatever errors I left, if any:)
Comment #22
joelpittetactivate testbot! and tag, also added a few new @todos that need some filling out in the twig file.
Comment #23
joelpittetSee #21 for notes on what further needs doing.
Comment #24
IshaDakota CreditAttribution: IshaDakota commented...and re-rolled.
-function system_admin_index() removed in #1987812: Convert system_admin_index() to a new style controller
-div container and class added to "no-screenshot" in #1861702: Add a responsive grid to the Appearance page. Resolved as such:
Comment #25
IshaDakota CreditAttribution: IshaDakota commentedComment #26
IshaDakota CreditAttribution: IshaDakota commented@joelpittet: Is this what you had in mind for for cleaning up the twig files? These were the only two cases I could find (in addition to the 2 you fixed).
and
Comment #27
joelpittet@IshaDakota Very close and in the right direction.
The first variable in the {% for ... is something you 'make up'. While container.block may work it's a bit confusing, the thing I was thinking of making may also be a bit confusing.
Which reads: For each block in container's blocks... print block's block.
The reason this is confusing, IMO, isn't my change but the property name block. So I'd prefer:
Which reads: For each block in container's blocks... print block's content.
This would mean changing a variable in the preprocces some place but by the looks of things you should be able to get away with this:
Which would be even better, so maybe give that a try and see if the admin page still does what it should.
Comment #28
IshaDakota CreditAttribution: IshaDakota commentedOK. I'll test that out.
Comment #29
IshaDakota CreditAttribution: IshaDakota commentedThe following seems to work in both the admin and admin index pages (see screenshots):
Admin Index Page:
Admin Config Page:
I'll check out those @todos in the twig files.
Comment #30
joelpittetGreat news @IshaDakota! Could you add the patch with that up?
This patch is getting pretty close, would like to get another set of eyes to review after that patch. Then we can move on to manual testing and profiling. (pre-emptive tagging.)
Comment #31
IshaDakota CreditAttribution: IshaDakota commentedThis is is the patch with #29.
There are still @todos in the status-report.html.twig file. Are those just to fill out the descriptions in the docblock? Or does it refer to the code? To me it looks OK.
Comment #33
joelpittet#31: 1987410-31-twig-system-theme.patch queued for re-testing.
Comment #34
joelpittet@IshaDakota, thank you and you are right, yeah, just to fill out the descriptions of what those variable are.
Below are another round of nitpikery:
Remove @todo, the issue it self can deal with it's removal
This should have it's own issue and not be a @todo. (may already exist, have a search before creating a new issue)
Remove 'Remaining '.
Should sa 'A list' and not refernce 'An array' @see https://drupal.org/node/1823416#datatypes
These todo's need to be filed out describing what these variables contain.
Need to add 'position' and 'block' to the available variables here.
Data types in twig dockblocks again @see https://drupal.org/node/1823416#datatypes
Comment #35
thedavidmeister CreditAttribution: thedavidmeister commentedComment #36
eromero1 CreditAttribution: eromero1 commenteddibs
Comment #37
sbudker1 CreditAttribution: sbudker1 commenteddibs!
Comment #38
sbudker1 CreditAttribution: sbudker1 commentedfirst patch failed here is a re roll!
Comment #39
sbudker1 CreditAttribution: sbudker1 commentedtest bot go
Comment #41
joelpittetRe-roll again.
Comment #42
joelpittetDoc cleanups from #34
Comment #43
eromero1 CreditAttribution: eromero1 commentedI installed the patch, and checked all of the fixed subjects noted at the top under "Theme function name". Everything ran smoothly and it appears as though the patch worked swimmingly.
Comment #44
star-szrThanks for testing @eromero1, this still needs profiling before we can RTBC it though. Did you perform manual testing (markup comparison) or just a visual run-through? If you can write up step-by-step instructions for how you tested each theme function that would be extremely helpful not only for manual testing but for profiling as well.
Comment #45
jenlamptonAlso, be aware that this is going to need a reroll after #1833932: Convert theme_system_compact_link() into a #type link
Comment #45.0
jenlamptonList of functions
Comment #46
Eric_A CreditAttribution: Eric_A commentedI looked at the
theme_status_report()
part and noticed two things in the patch from #42:This patch converts direct calls to
theme()
for the status_report hook to calls todrupal_render()
. (Why?). Also, this is already happening in #2009674: Replace theme() with drupal_render() in system module. See also #2006152: [meta] Don't call theme() directly anywhere outside drupal_render().This patch changes the status_report theme hook to take variables rather than a render element. (Why?) As it happens this has already happened in #2041283: theme_status_report() is severely broken, so the patch will need a re-roll anyways.
Comment #47
Eric_A CreditAttribution: Eric_A commentedAlso,
theme_status_report()
only prints the icon and rows when the #type key is empty, if I'm not mistaken. The template nor the new preprocess function take care of this now, it seems. Related: #2013258: Simplify render for theme_status_report().Comment #48
star-szrThanks for taking a look @Eric_A. Regarding your first point, if you look at the time stamps you can see the initial work on this issue predates all of the issues mentioned in #46. We've known for quite a while that we need to convert to render arrays.
If this needs a reroll, it should be set to needs work and tagged :)
Comment #49
pplantinga CreditAttribution: pplantinga commentedReroll.
Comment #50
Eric_A CreditAttribution: Eric_A commentedNeeds work per #47 and #46.
Comment #51
pplantinga CreditAttribution: pplantinga commentedReverted unnecessary theme() to drupal_render() changes, and removed two templates that only had {{ variable }} in them (they're unnecessary and slow). As for #47, that issue is outside of scope for this issue, let's let #2013258: Simplify render for theme_status_report() take care of it.
Comment #53
Eric_A CreditAttribution: Eric_A commentedIn #51 the code for the two templates was reverted but not the code for the preprocessors and theme functions. Also, #1939090: Convert theme_tablesort_indicator() to Twig had gone in already.
#2013258: Simplify render for theme_status_report()
and #2010982: Replace theme() with drupal_render() in system module for system_status() areis in, too.Comment #54
Eric_A CreditAttribution: Eric_A commentedSorry, #2010982: Replace theme() with drupal_render() in system module for system_status() is not in and not relevant here. Edited my earlier comment.
Comment #55
joelpittetOk I think there may have been some miscommunication here... #51 revert went a bit too far.
I took #49 which needed another re-roll. There aren't any theme to drupal_render switches that I can see.
@Eric_A could you try again with your review?
Comment #56
joelpittetComment #57
star-szrTime for another reroll.
Comment #58
star-szrThe chart in the issue summary should be updated with the status of the current patch as well.
Comment #59
joelpittetLooks like some things got dropped in favour of the routes, I like it:)
Here's the re-roll.
Comment #60
joelpittetRe-roll
Comment #61
pplantinga CreditAttribution: pplantinga commentedre-roll
Comment #61.0
pplantinga CreditAttribution: pplantinga commentedupdaed
Comment #61.1
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #62
star-szrTagging for reroll.
Comment #63
jeanfei CreditAttribution: jeanfei commentedRe-roll the #61.
Comment #64
jeanfei CreditAttribution: jeanfei commentedForget to change status to 'need review'.
Comment #65
mcrittenden CreditAttribution: mcrittenden commentedTags
Comment #66
joelpittetThis is missing the removal of
theme_system_modules_details
And hopefully the template is not {{ content }} as it is now, if so try to remove the template all together.Comment #67
rteijeiro CreditAttribution: rteijeiro commentedI will try to fix it :)
Comment #67.0
rteijeiro CreditAttribution: rteijeiro commentedUpdated issue summary.
Comment #68
joelpittetnever mind updated issue summary.
theme_system_modules_details will be removed in #1938930: Convert theme_system_modules_details() to #type table
Comment #68.0
joelpittetUpdated issue summary.
Comment #69
thedavidmeister CreditAttribution: thedavidmeister commentedTagging for #2094585: [policy, no patch] Core review bonus.
Comment #70
thedavidmeister CreditAttribution: thedavidmeister commenteddidn't mean to add that tag back on :(
Comment #70.0
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #70.1
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #71
joelpittetNeeds a re-roll, patch doesn't apply.
Comment #72
longwaveRerolled #63. Minor comment cleanup, and effectively reverted #1143922: Undefined index: value in theme_status_report() as explicitly checking for 'value' is not needed now we have Twig.
Comment #73
longwaveAlso changed .element-invisible to .visually-hidden.
Comment #74
joelpittetNice catch on the .visually-hidden. I didn't even see that conversion get in. For anybody looking that change record is here: https://drupal.org/node/2022859
Comment #75
star-szrUpdating the issue summary in preparation for splitting this up by function and making this a meta instead of an all-or-nothing issue.
Comment #76
star-szrCrossing out the theme functions that have actually been removed already.
Comment #77
star-szrConverting to a meta.
Comment #78
joelpittetComment #79
joelpittetComment #80
star-szrWoo, just one postponed issue left so I'm going to make that a child of #1757550: [Meta] Convert core theme functions to Twig templates instead. Great work everyone, making this and form.inc a meta really helped get this done! :D