Task
Clean up the remaining theme functions in comment.module. This was originally a Twig conversion issue but now the issue is about refactoring one theme function that doesn't belong in the theme layer (it just returns a string of HTML), and removing a stale definition from comment_theme() for theme_comment_preview().
Remaining
None at the moment.
| Theme function name | Conversion status |
|---|---|
| theme_comment_post_forbidden | Moved to CommentInterface::forbiddenMessage(). This really isn't necessary to go through the theme layer, per this comment. |
| theme_comment_preview | Removed. The callback definition in comment_theme() is removed, whilst the actual function was removed way back in #142829: Allow comment-$type.tpl.php |
Related Issues
#1898054: comment.module - Convert PHPTemplate templates to Twig
#1757550: [Meta] Convert core theme functions to Twig templates
#1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch
Review Bonus
See #2094585: [policy, no patch] Core review bonus.
Points: 3
- #607828: Allow passing variables that need to be saved to drupalCreateContentType(): +1 for being old
- https://drupal.org/node/2093161#comment-7889079
| Comment | File | Size | Author |
|---|---|---|---|
| #82 | 1987396-comment-theme-82.patch | 13.36 KB | joelpittet |
| #73 | 1987396-comment-theme-73.patch | 13.87 KB | andypost |
Comments
Comment #0.0
star-szrUpdated issue summary.
Comment #0.1
c4rl commentedUpdated issue summary.
Comment #0.2
c4rl commentedUpdated issue summary.
Comment #1
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 #1898054: comment.module - Convert PHPTemplate templates to Twig for template conversion.
Comment #2
star-szrHere are just the theme_ function conversions.
Comment #3
epersonae2 commented#2: 1987396-2.patch queued for re-testing.
Comment #4
brunodboAssigned to myself for DC PDX sprint.
Comment #5
brunodboReroll (since it didn't apply anymore) - hope I did that right, first time ever :)
Comment #6
brunodboUnassigning.
Comment #7
hydra commentedManual review looks good! Rerolled patch is applying properly. Still profiling to do!
Comment #8
jgraham commentedHere's my profiling info. Hopefully its correct.
Comment #9
jgraham commentedComment #10
jgraham commentedComment #11
ezeedub commentedre-tagging needs profiling, because same number of function calls in both runs:
Comment #12
ezeedub commented#5: 1987396-5.patch queued for re-testing.
Comment #13
ezeedub commentedAdd some comments, and place the recent comments block.
Not sure why, but I get a different number of function calls when comparing 8.x...8.x. I ran it a second time when I noticed this but got that again. Not sure why...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51a278c0bf3d5&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51a278c0bf3d5&...
Comment #13.0
ezeedub commentedUpdating from previous issue
Comment #14
ezeedub commentedComment #14.0
ezeedub commentedadd atttribution
Comment #14.1
ezeedub commentedUpdated issue summary.
Comment #15
star-szrNot sure if manual testing (markup comparison) was done on this, tagging. Adding manual testing steps to the issue summary would help with profiling as well.
Profiling results look reasonable, not much difference. Thanks @ezeedub!
Comment #16
joelpittet#5: 1987396-5.patch queued for re-testing.
Comment #17
thedavidmeister commentedmanual testing is a novice task
Comment #18
adamcowboy commentedNeeds Re-Roll.
Comment #19
adamcowboy commentedComment #20
adamcowboy commentedComment #21
jenlamptonrerolled.
Comment #22
jenlamptondoh, status.
Comment #23
jenlamptondoh, tags.
Comment #25
jenlamptonsyntax fixed
Comment #27
markhalliwellandypost mentioned in IRC that the "comment-block.html.twig" template was lost from #21 -> #25.
Comment #28
andypostMarked as duplicate #1914000: Convert l() call in template_preprocess_comment_block() into a render array to be handled by Twig. and closely related #1938062: Convert the recent_comments block to a view
Comment #29
andypostFiled separate issue to make block more sane #2054993: Remove (untested, unused, broken) comment_get_recent()
Comment #30
jenlamptonrerolled. Passing tests now :)
Comment #31
star-szrThis needs a reroll.
We can remove this change from the patch entirely. This was handled by #2008980: Replace theme() with drupal_render() in comment module.
We can remove this line.
Comment #31.0
star-szrUpdating commit message (pulling in people that I'm pretty sure worked on this as part of the .tpl.php conversion) and updating conversion table --Cottser
Comment #32
joelpittet@Cottser re #31 I don't think we should remove that change you listed in 1. regarding the change from drupal_render to the '#theme' as that is the way those should be going so they aren't rendered too early. Though if you want we can move it over to another issue? Maybe the one we have for drupal_render() removals?
Attached are re-roll and item 2.
Comment #33
star-szrThanks @joelpittet for rocking all these issues!
Yeah, basically I was thinking #31.1 (and maybe the following as well) feels out of scope for Twig conversion at this point and could be moved to a sub-issue of #2046881: [meta] Avoid "early rendered" strings where beneficial to do so, build structured data to pass to drupal_render() once instead.
Comment #34
joelpittetfollow up at #2073957: Remove useless "early render" in Comment Module
Comment #35
joelpittet#33 taken care of.
Comment #36
joelpittetOk this should be ready for manual testing and profiling. Test bot start!
Comment #36.0
joelpittetUpdate remaining
Comment #36.1
thedavidmeister commentedUpdated issue summary.
Comment #37
star-szrTagging for reroll.
Comment #38
hydra commentedRerolled
Comment #39
hydra commentedComment #41
joelpittet#38: 1987396-38-twig-theme-comment.patch queued for re-testing.
Comment #43
hydra commentedFixed the test after redirecting to the node when no access.
Comment #45
hydra commented#43: 1987396-43-twig-theme-comment.patch queued for re-testing.
Comment #45.0
hydra commentedUpdated issue summary.
Comment #47
andypostAlso
comment_prepare_author()is questionableComment #48
joelpittetThe last patch didn't apply anymore and rebasing a re-roll was super complicated so I manually re-rolled with some tweaks to how comment_block is done to hopefully remove the markup from the preprocess function and provide more data to the template.
Comment #48.0
joelpittetUpdated issue summary.
Comment #49
joelpittet48: 1987396-48-twig-theme-comment.patch queued for re-testing.
Comment #51
andypostI'd like to point that comments are rendered within field template so probable better to remove comment-wrapper
Comment #52
joelpittet@andypost do you mean that comment-wrapper is not used at all now? If so, I'll open up a separate issue for that and remove it. This is a conversion issue so I'd rather not double up on it's reasons not to get committed.
Thanks for checking in on this issue:)
Comment #53
joelpittetHmm that being said, I've done things to this patch that aren't straight conversion already. Here's a reroll to get it applying again.
So up to you @andypost do you think if I remove that rapper it would still be good to get in or should it be a separate issue?
Comment #55
andypost@joelpittet Yep, I think comment wrapper is useless and should be removed, I'd suggest to make it in #1962846: Use field instance name for header of comment list, drop comment-wrapper template
Also we really need to use field name as header because "Comments" could be "Reviews", "Discussions" ant etc. and node could have more then one comment field attached
Comment #56
joelpittet@andypost ok good to note, I'll leave it to that issue to make those changes. We'll keep an eye on that issue.
comment-wrapper.html.twig (other than moving the hook_theme declaration of 'template' to the bottom) is not in this issue.
Comment #57
joelpittet#2061899: Remove references to global $user in Comment module is dealing with the global $user; so I reverted that in this patch.
Comment #59
joelpittetRe-rolled.
Comment #61
joelpittetThis doesn't have any actual twig conversions anymore, it's become cleanup and replacing the message theme with a function.
Comment #62
joelpittetComment #63
andypostAwesome clean-up!!! I'd like to get @larowlan opinion on proposed change
Also comment wrapper should be removed in #1962846: Use field instance name for header of comment list, drop comment-wrapper template
This function builds a "login or register to post comments" links so better to put it into commantManager.
Also there's drupal_static used so probably we can get rid of it
Comment #64
larowlanYeah, I agree with @andypost, please move this to the CommentManager and the static to a new property on the manager. We're trying to avoid adding new global functions.
Otherwise, +1.
Comment #65
larowlanMoves comment_forbidden_message to \Drupal\comment\CommentManagerInterface::forbiddenMessage
Comment #66
joelpittetLike this?
Comment #69
andypostCleaned-up implementation of #65, RTBC because there's agreement.
Summary updated with latest change, also fixed commit message
Comment #71
joelpittet$entity->$field_name->
should be
$entity->{$field_name}->
if that is the way you are trying to do it.
Comment #72
andypost69: 1987396-comment-theme-69.patch queued for re-testing.
Comment #73
andypostCan't reproduce failure locally.
Changed this line to more performant getter (skipping magic method call)
PS: #71 both syntax is fine
Comment #74
star-szrLet's retitle this if there is no Twig conversion happening - something like "Refactor comment.module theme functions"?
Comment #75
joelpittetAgreed, and it's ready to go.
Comment #76
markhalliwell+1
Comment #77
star-szrRemoving the suggested commit message from the summary, this patch changed direction quite a bit.
Comment #78
star-szrAlso updating the body of the issue summary to reflect the latest patch.
Comment #79
star-szrs/converting/refactoring/
Comment #80
star-szr73: 1987396-comment-theme-73.patch queued for re-testing.
Comment #82
joelpittetre-roll (super minor comment.admin.inc removed, was a comment change)
Comment #83
catchLooks great. Committed/pushed to 8.x, thanks!