Task

Use Twig instead of PHPTemplate

Twig sandbox: http://drupal.org/sandbox/pixelmord/1750250

Remaining

  • Minor documentation and Twig coding standards tweaks

Testing steps

Visit admin/structure/types and inspect the dropbuttons that list actions e.g. Manage Fields, Manage Display, Edit, Delete.

Related

#1885560: [meta] Convert everything in theme.inc to Twig

Comments

chrisjlee’s picture

StatusFileSize
new2.34 KB

Trying to get things rolling. Not sure what to do with converting render elements. Anyone have any ideas?

chrisjlee’s picture

Status: Active » Needs work
star-szr’s picture

Status: Needs work » Needs review

The only thing confusing me is the check for if dropbutton_wrapper is defined.

The render element should be fine, the Twig engine will handle rendering it. Looks like a good start, sending for review. Thanks @chrisjlee!

Status: Needs review » Needs work

The last submitted patch, 1939086-1.patch, failed testing.

chrisjlee’s picture

@Cottser I don't need to check if dropbutton_wrapper is defined do it?

star-szr’s picture

I don't see where dropbutton_wrapper would be defined, since it's not in the preprocess function. I haven't tested the patch but I think if you remove those lines we might see different test results.

Thanks again!

chrisjlee’s picture

StatusFileSize
new2.28 KB

@cottser Thanks! I didn't know that. I'll give that a try.

chrisjlee’s picture

StatusFileSize
new990 bytes

interdiff for #7

chrisjlee’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: -Twig

The last submitted patch, 1939086-7.patch, failed testing.

chrisjlee’s picture

Status: Needs work » Needs review

#7: 1939086-7.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Twig

The last submitted patch, 1939086-7.patch, failed testing.

chrisjlee’s picture

StatusFileSize
new2.28 KB

reroll patch. i hope i do this correctly.

hefox’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1939086-13-reroll.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new2.75 KB
new2.48 KB

Did some doc cleanup, changed the filename to use hyphen's instead of underscores and did some whitespace cleanup. And made the twig docblock a real docblock. Tests seem to pass locally... so we'll see.

Nice work getting this started @chrisjlee! If you see anything else that could be fixed, feel free to reroll.

Status: Needs review » Needs work

The last submitted patch, twig-dropbutton-wrapper-1939086-16.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new1.34 KB
new2.49 KB

same, wrong site tested... this should be better.

star-szr’s picture

Literally the only thing I could find wrong with this:

+++ b/core/includes/theme.incundefined
@@ -3126,6 +3112,22 @@ function template_preprocess_region(&$variables) {
+ * Preprocess variables for a dropbutton wrapper template.

s/Preprocess/Prepares.

Other than that, RTBC :)

star-szr’s picture

+++ b/core/includes/theme.incundefined
@@ -3126,6 +3112,22 @@ function template_preprocess_region(&$variables) {
+ * Default template: dropbutton-wrapper.html.twig

Oh, and this needs a period at the end. So two things :) Thanks guys!

star-szr’s picture

Issue tags: +Needs manual testing

This could use manual testing as well.

chrisjlee’s picture

Small tweaks as requested in 19/20.

chrisjlee’s picture

Forgot to hit save while editing theme.inc the second time.

Please ignore #22.

star-szr’s picture

Thanks a bunch @chrisjlee! I missed these two before:

+++ b/core/includes/theme.incundefined
@@ -3126,6 +3112,22 @@ function template_preprocess_region(&$variables) {
+ * Prepares variables for a dropbutton wrapper template.

Prepares variables for dropbutton wrapper templates. (remove 'a', and plural templates at the end, missed this before).

+++ b/core/modules/system/templates/dropbutton-wrapper.html.twigundefined
@@ -0,0 +1,23 @@
+ * @see template_preprocess_dropdownbutton_wrapper()

template_preprocess_dropbutton_wrapper() - dropbutton instead of dropdownbutton.

chrisjlee’s picture

@Cottser Thanks for the feedback!

star-szr’s picture

Status: Needs review » Needs work
Issue tags: -Needs manual testing

Markup matches exactly, two tiny tweaks and then this is ready to go.

+++ b/core/modules/system/templates/dropbutton-wrapper.html.twigundefined
@@ -0,0 +1,23 @@
+ * Default theme implementation for a dropbutton menu.

I think this should say "for a dropbutton wrapper."

+++ b/core/modules/system/templates/dropbutton-wrapper.html.twigundefined
@@ -0,0 +1,23 @@
+{% spaceless %}
+{% if children %}
+  <div class="dropbutton-wrapper">
+    <div class="dropbutton-widget">
+      {{ children }}
+    </div>
+  </div>
+{% endif %}
+{% endspaceless %}

The contents of the {% spaceless %} tag should be indented per Twig coding standards.

star-szr’s picture

Issue tags: +Novice

The above would be a great Novice task.

chrisjlee’s picture

Assigned: Unassigned » chrisjlee
StatusFileSize
new2.5 KB
new983 bytes

Sorry i read this issue then forgot to get back to it. I'll finish this one off.

chrisjlee’s picture

Status: Needs work » Needs review
chrisjlee’s picture

Updated as per discussion and review with Cottser over IRC

chrisjlee’s picture

StatusFileSize
new908 bytes

Interdiff for #30

chrisjlee’s picture

arg forgot to interdiff.

chrisjlee’s picture

Fixed Children indentation back again.

star-szr’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Thanks @chrisjlee! RTBC once it comes back green.

Manual testing looks good, code and documentation look good, this is ready :)

tim.plunkett’s picture

+++ b/core/includes/theme.incundefined
@@ -3125,6 +3111,22 @@ function template_preprocess_region(&$variables) {
+function template_preprocess_dropbutton_wrapper(&$variables) {
+  if (!empty($variables['element']['#children'])) {
+    $variables['children'] = $variables['element']['#children'];
+  }

There's no generic way to do this? Or something to change in hook_theme()? It just seems very non-specific and wasteful.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.21 KB
new1.97 KB

How about this?

steveoliver’s picture

Status: Needs review » Needs work

Nice. Just one quick thing.

+++ b/core/modules/system/templates/dropbutton-wrapper.html.twig
@@ -0,0 +1,23 @@
+{% spaceless %}
+  {% if children %}
+    <div class="dropbutton-wrapper">
+      <div class="dropbutton-widget">
+        {{ children }}
+      </div>
+    </div>
+  {% endif %}

Since {% spaceless %} has no effect on the contents of tags, in this case the {% if children %} check, the spaceless tag should be inside the children tag.

chrisjlee’s picture

Status: Needs work » Needs review
StatusFileSize
new1.97 KB
new618 bytes

Changes applied as per #37.

star-szr’s picture

Status: Needs review » Reviewed & tested by the community

Thanks everyone, especially @tim.plunkett, that's much better.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +needs profiling
thedavidmeister’s picture

Assigned: chrisjlee » Unassigned
jenlampton’s picture

Status: Needs work » Needs review

Think this was meant to be needs review (&profiling), not needs work (&profiling)?

fabianx’s picture

#36: Very nice change!

star-szr’s picture

Assigned: Unassigned » star-szr

Working on profiling this one.

star-szr’s picture

Assigned: star-szr » Unassigned
Status: Needs review » Needs work

Numbers don't look so great for this one, performance will need some work.

Scenario: A simplified version of admin/content, displaying 50 dropbutton wrappers.

=== 8.x..8.x compared (51ff119b87ac8..51ff13036383a):

ct  : 108,200|108,200|0|0.0%
wt  : 460,107|459,457|-650|-0.1%
cpu : 413,141|414,199|1,058|0.3%
mu  : 16,384,728|16,384,728|0|0.0%
pmu : 16,481,400|16,481,400|0|0.0%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ff119b87ac8&...

=== 8.x..dropbutton-1939086-38 compared (51ff119b87ac8..51ff136e6df0a):

ct  : 108,200|110,138|1,938|1.8%
wt  : 460,107|465,904|5,797|1.3%
cpu : 413,141|419,799|6,658|1.6%
mu  : 16,384,728|16,426,480|41,752|0.3%
pmu : 16,481,400|16,516,480|35,080|0.2%

http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ff119b87ac8&...

fabianx’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -needs profiling

Yeah, that is the usual theme function vs. twig templates performance difference. (Thats around 0.1 ms per call) (can be seen better here: http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?symbol=theme%404&ru...)

Do we anticipate this being used on non-admin pages?

If not, this can straight go in as 5ms on a 460ms page is not much (and admin only).

Setting back to RTBC and leaving decision for alexpott.

webchick’s picture

Assigned: Unassigned » catch

Hm. Assigning to catch to give an opinion on those #s. I don't think dropbutton is used by core outside of admin pages, but contrib can always do weird stuff.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Hmm this is really an admin-facing theme function, if contrib uses it for visitor-facing stuff they would indeed be doing something quite weird. Given that I think the regression is OK - there's other stuff on admin/content we could likely optimize if we had a proper look at it.

Committed/pushed to 8.x.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Update remaining, add testing steps