This is a Meta issue.
You could call it a plan, like on the Etiquette page
So, no patches here please! Instead
- Place patches in their respective child issue (see sidebar for child issues)
- If there is no child issue yet, create one and mark this post as its parent. And then place patches there.
- Test and review patches in the child issues.
Thank you!
Original post:
Use of theme functions is discouraged in D8 and removed in D9 in favor of using Twig templates.
All theme function in includes/fivestar.theme.inc should be replaced by templates in templates/ and hook_theme() should be modified to use these templates.
| Comment | File | Size | Author |
|---|
Issue fork fivestar-3133125
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
tr commentedComment #3
tr commentedHere's a start. This patch removes two Field Formatter theme functions and replaces them with preprocess hooks and twig templates.
The removed functions are:
theme_fivestar_formatter_rating()
theme_fivestar_formatter_percentage()
They are replaced with:
template_preprocess_fivestar_formatter_rating()
template_preprocess_fivestar_formatter_percentage()
With templates:
templates/fivestar-formatter-rating.html.twig
templates/fivestar-formatter-percentage.html.twig
This could probably be simplified a lot further by moving the preprocess logic into the Field Formatters, but for now this closely sticks with what we are currently doing so it reduces the potential to be disruptive. Likewise, I hope this will serve as an example of how to convert the other theme functions to templates.
Comment #5
init90Thank @TR for the nice examples. Here migration of static output function.
Comment #6
init90Here relevant issues with which I encountered when worked on it: #3142319: Move static theme output into twig templete and #3142322: Attach necessary library for static rating output
Added link to related issue into the patch.
Comment #7
init90Added related function.
Comment #8
v.hilkov commentedMy humble attempt to replace theme functions. Updated fivestar_static_element, fivestar_summary and fivestar_preview_widget functions. I couldn't find where functions fivestar, fivestar_select, fivestar_preview, fivestar_preview_wrapper and fivestar_formatter_default are used. Are they needed at all? Looks like everything is working right now even without them. Maybe someone can point me in the right direction, so when I have free time I can try to update them as well if needed.
Comment #9
o'briatOk
fivestar_statictheme function is still on '8.x-1.0-alpha2' but not on dev.Comment #10
tr commentedHi @V.Hilkov
Thanks for your help. Can you make a new issue for each theme function you are replacing, like @init90 did with #3142319: Move static theme output into twig templete? One issue for each theme function. Then add those issues here as Related issues. That will make it easier to review and discuss your changes, and will allow me to give you credit for the commit.
Also, don't comment out code in your patch - just delete the lines that you no longer need.
Comment #11
o'briatIt's ok , I missed the fact that the other theme fixes are already on the dev branch and not on the last alpha.
So far dev + patch seems ok.
Comment #12
v.hilkov commentedHi @TR
I did as requested and made different issue for every theme function, which I was able to replace. Also my previous question still stands: I couldn't find where functions fivestar, fivestar_select, fivestar_preview, fivestar_preview_wrapper and fivestar_formatter_default are used. Are they needed at all? Looks like everything is working right now even without them. Maybe someone can point me in the right direction, so when I have free time I can try to update them as well if needed.
Comment #13
tr commentedI don't know. They have to be looked at one-by-one to see. Some may be used by other theme functions. Some may be for features that have not yet been ported to D8. Some may be for features that are no longer needed in D8. You will have to look at the D7 code to see how they were used, then see how that code got ported to D8 to figure out why the code is still there. We may be able to delete a lot of that, but not before we make sure that everything got properly moved from D7. A lot of things were not ported, or were incompletely ported.
Comment #16
tr commented@Yuriy Mykhalyna
This is a meta issue - patches aren't being evaluated here. Instead, see the related issues in the right sidebar for the issues where the patches are being reviewed. There is one related issue for each theme function.
Comment #17
rohan_katkar commentedI have tried below patch links through composer but its not working for me..
Patch link: https://www.drupal.org/files/issues/2020-11-21/replace-theme-functions-3...
I am getting below error:
The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-11-21/replace-theme-functions-3...
When I ran "composer update" the inside fivestar module, folder called "b" is there, which includes below twigs:
Comment #18
tr commented@rohan_katkar Please read what I said in #16.
The patch in #8 will not be considered or supported. The patches that are being considered are in the child issues. Please use those patches and comment in those issues.
Comment #19
j.lucky commentedJust Update the Patch and remove the commented line.
Comment #20
rivimeyMeta issues don't have patches so I've hidden them.
Comment #21
pbbhoge commentedRe-rolled the patch
Comment #22
rivimeyComment #23
pbbhoge commentedComment #24
rivimey@pbbhoge, Did you not see @TR 's post in #16?
Please do not upload patches or comment on those already uploaded.
Comment #25
kiseleva.t commentedExported the changes from MR to a static patch file to be able to use it on the project without the risk that it will be changed or removed.
Comment #26
tr commentedNo. Everyone please stop posting patches here. This is not helping. If you want to help, participate in the child issues.
Comment #27
tr commentedComment #28
o'briatI'm currently reviewing child issue #3186841, but I am missing something or there should be 4 more child ones:
theme_fivestar,theme_fivestar_select,theme_fivestar_preview&theme_fivestar_formatter_default?Comment #29
rivimeySome theme conversions are already done and some were subsumed:
So I think maybe yes, we are missing one or more child issues.
Comment #30
o'briatfivestar_preview has not been removed in #3186841, this issue only deals with fivestar_preview_widget & fivestar_preview_wrapper.
So I will create 4 child issues and try dispatch this issue patches into them.
Ok ?
Comment #31
rivimey@O'briat if you are sure the theme functions are not covered in another issue, and are also still required by the module, please do add new issues for them.
Once done, please add the new issues referenced as child issues (that is, in the new issue, reference this one as parent.)
Thanks for your efforts.
Comment #32
johan den hollander commentedHi,
I looked at the child issues and could not find a solution for: theme_fivestar_select.
I'm using the dev version with the #22 patch from https://www.drupal.org/project/fivestar/issues/3186841.
Comment #33
johan den hollander commentedIn fact I still have deprecation messages for all of the following:
Comment #34
init90One more step forward #3186841: Move preview wigdet theme output into twig template
Comment #35
ravimane23 commentedAdded patch after removed all the remaining theme function.
I applied a patch manually reason the patch #25 unable to apply automatically.
In addition to patch, I also faced an issue that I am using layout_builder & star format for rating but if the rating is empty then no field is getting displayed on node view page eventhough field is present in layout. I took a reference of "Fivestar widget not displayed when using Layout Builder" I have added the code and it resolves my issue.
Comment #37
tr commented@ravimane23: You need to read everything on this page.
Comment #38
tr commentedComment #39
init90Comment #40
init90Comment #41
init90Comment #42
nicolas bouteille commented+1 for deprecation message for theme_fivestar_preview after module install via UI or cache clear.
User deprecated function: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of theme_fivestar_preview()
Comment #43
init90Comment #44
saurabh-2k17 commented@Nicolas Bouteille any solutions for the issue you faced? I am seeing the same thing on my site after cache-clear.
Comment #45
firfin commented