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
Use Twig instead of theme function
Remaining
- Replace all theme functions with .html.twig equivalent templates
- Add new preprocess functions for the .html.twig equivalent templates
- Update all hook_theme definitions
Comment | File | Size | Author |
---|---|---|---|
#108 | convert-1963978-108.patch | 7.57 KB | NickDickinsonWilde |
Comments
Comment #1
star-szrTagging.
Comment #2
joelpittetSplit from meta
Comment #3
joelpittetDamn it's like tag caching or something... get back in there!
Comment #5
joelpittetWrong twig file from split.
Comment #6
star-szrThis will need a quick reroll now that #1963976: Remove theme_views_tab() and theme_views_tabset() declarations from views_ui_theme() is in.
Comment #7
2ndmile CreditAttribution: 2ndmile commentedReroll of #5 - please make sure I did this correctly as this is my first contribution.
Comment #8
star-szrReroll looks great, thank you @2ndmile!
Comment #9
thedavidmeister CreditAttribution: thedavidmeister commentedReview for #7:
Awful lot of undocumented variables with @todo in the Twig template here. Not sure if this should prevent an RTBC status considering the nature of the patch but I've added a "@todo clean-up" tag.
+ * - table: A rendered table element of the group filter form..
Don't need the double dot at the end.
+ '#attributes' => array('class' => array('views-filter-groups'), 'id' => 'views-filter-groups'),
This line is part of a multi-line array and it is over 80 characters itself. Looks like it should probably be split over multiple lines itself.
+ 'class' => array('views-hidden', 'views-button-remove', 'views-groups-remove-link', 'views-remove-link'),
+ $variables['table']['#rows'][] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable'));
More long arrays that could be split across multiple lines.
+ $remove_link = array(
Indentation is wrong here.
+ '#theme' => 'link',
Including this means that this patch can't be RTBC until #1922454: Gut l(), fix theme('link'), have a working framework for consistently generated links inside and outside of Twig lands.
This patch is tagged as "needs manual testing" but there are no manual testing steps included in the issue summary - these need to be written and somebody needs to do the manual testing.
Comment #10
thedavidmeister CreditAttribution: thedavidmeister commentedComment #11
joelpittetDid the doc cleanup from #9 thank you @thedavidmeister! :)
Comment #12
tim.plunkettInstead of all of this, why not just:
Oh these too.
Comment #13
star-szr#12/@tim.plunkett - That would certainly be cleaner, thank you :) I think this whole thing can be refactored ala #1898432-54: node.module - Convert PHPTemplate templates to Twig. Probably no need to prepare all those variables in preprocess (other than 'table' from what I can see at a glance).
Should be able to just use e.g. {{ form.more }} in the template.
I'll investigate.
Comment #14
damiankloip CreditAttribution: damiankloip commentedSee #1984850: Convert FilterPluginBase::build_group_form to use table rendering and remove theme function. It's likely that all views ui forms will get a conversion issue. There have been a few already.
Comment #15
star-szr@damiankloip - thank you! It looks like this will be fully converted by #1984850: Convert FilterPluginBase::build_group_form to use table rendering and remove theme function.
Comment #15.0
star-szrRemove sandbox link
Comment #16
star-szrSince #1984850: Convert FilterPluginBase::build_group_form to use table rendering and remove theme function is no longer removing that theme function, it seems we should reactivate this issue and just get it converted to Twig.
Comment #17
lauriiiComment #18
lauriiiRerolled the patch
Comment #19
joelpittetRefactored this to clean it up from the older patch. Fixed #theme link which is now #type=>link.
Did most of the @todo's but left a couple in there. Maybe someone can test this and fix those @todo.
Comment #21
realityloopComment #22
Manuel Garcia CreditAttribution: Manuel Garcia commentedRerolling the patch...
Comment #23
Manuel Garcia CreditAttribution: Manuel Garcia commentedHere is #19 rerolled.
Comment #24
dawehnerJust curious, what renders the actual thing then? (not all of those are printed out earlier)
Someone really has to write proper tests and use data instead.
Comment #26
lauriiiComment #27
star-szrComment #28
joelpittet@dawehner thanks for the review, we are having an issue right now trying to see this template.
We think it may be here:
But we can't open that link. Maybe it's broken? Is there another way to get at this form through the UI?
RE:
#24.1 The only 3 that are excluded there are in the table. I could be very wrong there as that table build up is a bit strange using #rows where as #type=>table usually doesn't specify #rows those are the child elements.
#24.2 I agree it should be using data attributes, this is however just a conversion issue we can create a follow-up to address that.
Comment #29
joelpittetThis seems to be related to #2168893: Views filters groups adding and removing is broken
Comment #30
joelpittetRerolled. And left the remove link structure more or less alone.
The add group button still doesn't work before or after this patch, but everything else seems to with manual testing.
Also instead of using |without on the items that are built up in the table and not printed in the template explictely I hide() on them the preprocess so they are easy to spot.
Maybe we can just put this in without that group filter things fixed? The related fix for that doesn't seem to be touching any template logic.
Comment #31
joelpittetWhoops @todo cleanup is still a thing, gotta figure out what those things are...
Comment #35
joelpittetThis ones just needs to get green again, the bugs in the JS look to be resolved in the RTBC #2168893: Views filters groups adding and removing is broken
Comment #37
joelpittetWhoops, poor re-roll from #30 I don't trust myself at this hour.
Comment #38
dimaro CreditAttribution: dimaro at La Drupalera by Emergya commentedI start by trying to fix the syntax error.
Hope it works!
Although I think possibly errors in the test.
Comment #40
joelpittet@dimaro thanks for getting it to not have that syntax error, I managed to make another one here I believe from the test results:
This is like PHP where it doesn't like that ending comma in a function/filter.
@dimaro, Do you want to see how many fails/exceptions this fixes? If you have any idea what those twig variables with @todo actually are could you attempt filling out the ones you know? That would be a huge help! Views in D7 is lacking for their documentation mostly because it's admin facing.
Comment #41
NickDickinsonWildeSeeing as I was mucking around with the views filters, I wanted this completed so that I could properly theme it in my theme.
So basically finished this up.
Comment #43
NickDickinsonWildeforgot to include the one file in my patch.
Comment #44
joelpittet@NickWilde thank you very much for tackling one of few theme functions left. Just a couple of questions and nitpiks:
Also thanks for finishing all those @todos, I really didn't know what half of them were:)
This looks a bit out of scope can you explain this change?
Nit: Extra space before the A
Should wrap this on two lines for the 80 character coding standard for comments.
Need a new line at end.
Does this hunk need to change location?
We don't need to do the array syntax changes that affect this patch size. We try to make that change on only parts of the patch that are changing so that it's easy to review the patch without doing the mental gymnastics around what is a syntax change and what is critical change part of the patch. (loose rule)
Great work and green patches are always nice to see!
Comment #45
rishikant05 CreditAttribution: rishikant05 at Srijan | A Material+ Company commentedComment #46
NickDickinsonWilde@joelpittet
Well I like to have good documentation. At least when I'm editing code... writing new code I tend to document on the slim side of what I will like if I edit the area later. Nit picks are always appreciated :)
1. That really really is in needed - might be out of scope slightly but if so it should be done as a seperate patch. That change hides the div with the label and the checkbox or radio button for the default selection - without that change it was displaying two labels and either the checkbox or the radio button (in the table of options)
2. fixed
3. fixed - it was from the old patch and didn't notice the length of it.
4. fixed
5. Not really. Fixed
6. that's from inherited from the older versions, should I change that out?
Thanks;
Nick
Comment #47
rishikant05 CreditAttribution: rishikant05 at Srijan | A Material+ Company commentedComment #48
joelpittet@NickWilde thanks for the quick fix.
Re #46.5 probably my bad :P, but yes please do. You can keep the short syntax in hunks that have changed but otherwise please revert, the committers will thank you and the reviewers too:)
#46.1 Hmm, I wonder if that is being taken care of already in #2168893: Views filters groups adding and removing is broken? Or at least that sounds like the last comments were referring to? Regardless, let's take that out so it doesn't block this patch from going into core. Maybe create a follow-up issue for that and let us all know about it so we can test and push that fix in on the JS.
Couple more things, the fixes look great thanks again!
"... selected filter values ..." or "... the selected filter value ..."? Needs plural or an article qualifier.
Both of these should be inline comments. //
And have space before the comment, uppercase the first character in the sentence and period at the end as per our coding standards.
Comment #49
NickDickinsonWilde#46.1 reverted that on the lines that was the only change
#46.2 removed and I'll look into doing it as a separate patch
#48.1 fixed (also removed another variable description as it doesn't actually exist in this form).
#48.2 fixed
Thanks;
Nick
Comment #50
NickDickinsonWildeComment #54
NickDickinsonWildeI just regenerated the patch and got the same content. Do you think that is a testbot failure? or something I need to deal with? With those changes it is running fine in usage.
Thanks
Nick
Comment #56
star-szr@NickWilde great stuff! Sometimes looking at the detailed testbot results will show a PHP fatal error, or that some tests are failing or throwing exceptions. But I didn't see any of that, so giving it another spin.
Comment #57
star-szrA couple minor points, but it's green now :)
I'd say indent everything inside the div.clearfix here.
Maybe this should either just be alphabetized or should follow the order in which the other elements are printed.
Comment #58
NickDickinsonWilde1. indented.
2. ordered to be the same as they are printed. (and removed a couple of invalid ones while I was examining that part)
Thanks;
Nick
Comment #60
NickDickinsonWildeoops
Comment #62
joelpittetThe latest patch says:
When I try to apply it. Did you maybe try to remove something directly from the patch file instead of creating a new patch?
It says the new html.twig file is
@@ -0,0 +1,71 @@
meaning 71 lines, yet there are only 68 lines in the patch from my count.It's possible to remove lines from a patch file but the numbers there need to change too. IMO it's not worth the hassle, let git do it.
Comment #63
star-szrYup, let git do it, and when you let git do it you can also make interdiffs which are very useful for getting your patch reviewed quicker. And that is usually the biggest thing that we lack is patch reviews! :)
Comment #64
NickDickinsonWildeoh good job Nick... I always use git (1/2 dozen commits make up this patch on my end). Except for this once when it was all done except that tiny change and then I go and forget to change the line numbers whooo.
fixed numbers attached.
Comment #65
NickDickinsonWildeComment #66
joelpittetThank you again @NickWilde. I'd likely do that manual patch edit and post it too, no worries;) I think we just need someone to do a bit of manual testing now. It's a bit tricky since it's kind of broken. The JS patch in #2168893: Views filters groups adding and removing is broken and that other JS code you had would help the manual testing along.
We just need to confirm the markup is identical before and after this patch. And that it still works.
To that task there is one more thing I spotted:
This looks as it would cause a dup, since we aren't converting the drupal_render in this hunk. I think the critical is dealing with this so we can remove this added line.
Comment #67
NickDickinsonWildehmm that is a line I didn't add so I'm not actually sure on it. I'll do some manual testing and checks into removing it and functionality testing too.
(was away yesterday)
Comment #68
NickDickinsonWildealrighty did some testing.
Markup is *not* identical. I intentionally made some changes. See screenshot for the example of messed up spot that is fixed with this partch. All functionality works as well or slightly better than before - still need some javascript work but that is seperate from this.
Comment #70
NickDickinsonWildeof course it would be good if I uploaded the right patch.
Comment #71
NickDickinsonWildeI have now uploaded that JavaScript improvement that was in an earlier version of the patch to a new issue
Comment #72
joelpittetAdding the other issue for dragging and dropping. #2493945: Views filters dragging in the grouping view is broken
Comment #73
joelpittetRe-rolled.
Comment #74
joelpittetRemoved clearfix, no longer in head.
Comment #75
joelpittetRemoved a bunch of things from the template that weren't in the theme function anymore.
Comment #76
joelpittetRemove the last drupal_render() early render call from there and make the
unset()
's more specific so they don't accidentally remove something they shouldn't from the form.Comment #77
joelpittetMissed a few more
drupal_render()
calls. That should be the last of them.Comment #78
joelpittetI've done a manual test and it looks like currently without the patch that form is quite broken. Also some of the screenshots I took above are totally the wrong form (those were for reorganizing the filters, while this is for grouping exposed filters)
Attached is whitespace normalized before and after with twig debug turned on so I know it's the right template this time.
Before:
After:
Maybe someone can confirm my findings here and RTBC?
It looks like the radios are just printed twice before this patch fixes that.
Comment #82
star-szrSorry for the noise, testbot is backed up for some reason so I cancelled some of the in between patches.
Comment #83
jmolivas CreditAttribution: jmolivas at FFW commentedI am testing this and do a little code cleanup.
Comment #84
jmolivas CreditAttribution: jmolivas at FFW commented@joelpittet Look good to me, radios are printed once.
I am uploading a patch including:
- Remove unused use statements at views_ui.module
- Switch to the short array syntax.
Comment #88
tim.plunkettThis patch went from 7K to 32K somehow...
Changing lines like this is out of scope, please revert.
Comment #89
joelpittetThanks for the manual testing @jmolivas.
Yeah we don't go out of our way to make changes unrelated to the task or it's a) Hard to review the changes b) Could unintentionally make patches on the same file need to re-roll. I like short syntax as much as anybody but we need to be tactical on that kind of change;)
Re-posting #77. Let me know if there is anything in #84 that made the conversion to Twig better?
Comment #90
jmolivas CreditAttribution: jmolivas at FFW commented@joelpittet Besides the short syntax at #84 I did also remove these unused use statements:
Comment #91
jmolivas CreditAttribution: jmolivas at FFW commented@joelpittet Also thanks for reposting #77 and remove my mess ;)
Comment #92
joelpittet@jmolivas I don't see those use lines in my version of head, maybe your working directory is behind?
This is all I see:
Comment #93
jmolivas CreditAttribution: jmolivas at FFW commented@joelpittet I was talking about
views_ui.module
I did the changes since the file was already updated by the patch, but may be this is also out of scope.Comment #94
joelpittetI'd say it may be out of scope because we aren't removing any of those use in the code below, but maybe @tim.plunkett has an opinion on the matter?
*Putting my hands up to look like a scale* Those removals end up in really small patch issues "Remove unused use statements in blah file". Which is also not fun for committers...
Comment #95
jmolivas CreditAttribution: jmolivas at FFW commentedComment #96
jmolivas CreditAttribution: jmolivas at FFW commented@joelpittet: Maybe not fun but needed to get fixed but if not good for a new issue, but also not good when file is already updated with a patch when this can happen.
Comment #97
joelpittet@jmolivas maybe just add it here and we'll see if it gets kickback;)
Comment #98
jmolivas CreditAttribution: jmolivas at FFW commentedI will and wait
Comment #99
jmolivas CreditAttribution: jmolivas at FFW commentedjoelpittet: Removing unused use statements at views_ui.module and just waiting to see if it gets kickback;)
Comment #100
star-szrOnly found a couple minor docs things, otherwise this looks great to me.
This should probably say "Views UI" somewhere, maybe.
Since this is a list it needs to end in a colon, we usually do something like end it in ", including:" or ", containing:" or similar. This is for api.d.o parsing I think. See https://www.drupal.org/node/1354#lists.
Comment #101
jmolivas CreditAttribution: jmolivas at FFW commentedcottser: I updated the docs trying to follow your recommendation at #100
Comment #102
damiankloip CreditAttribution: damiankloip commentedNot really. No one will get hurt if it didn't. Very minor stuff :) That tangent wasted a couple of days...
On the plus side, the manual testing really is appreciated.
Comment #103
joelpittet@damiankloip Rather a couple of days discussing the issue and learning about core contribution stuff than months++ sitting stagnant. It helps a crap ton just to have eyeballs!
Comment #104
joelpittetFor my motivation too!
Comment #105
jmolivas CreditAttribution: jmolivas at FFW commentedUploading fixes to the doc suggested by @cottser since seems like files were deleted on #102
Comment #106
damiankloip CreditAttribution: damiankloip commented@joelpittet agree. Eyeballs are king in these here issue queues!
Comment #107
star-szrThanks!
This is a bit awkward now, and looking at this again I'm not sure adding a comma before 'containing' will fix it. What about "A render element representing the form. Contains the following:"
These usually start with "Default theme implementation", so I'd put Views UI before "build group filter form" instead :)
Otherwise RTBC from me.
Comment #108
NickDickinsonWildeSame as patch in #105 but with @Cottser's doc improvements from #107 applied. (ie no other changes and I'm not making an interdiff for those two lines of documentation)
Comment #112
star-szrLooks good, thanks @NickWilde!
Comment #115
lauriiiBack to RTBC
Comment #116
alexpottNice twigifying. It's really nice to be getting rid of all the calls to drupal_render(). Committed 08baa72 and pushed to 8.0.x. Thanks!