Issue #1963476 by widukind, tlattimore, joelpittet, kattekrab, carsonevans | Cottser: datetime.module - Convert theme_ functions to Twig.

Task

Use Twig instead of PHPTemplate

Remaining

  • Code review
  • Manual testing

Theme function name/template path Conversion status
theme_datelist_form converted
theme_datetime_form converted
theme_datetime_wrapper converted

Testing steps

  • Navigate to node/add/article, compare the markup for the 'Authored on' field in the 'Authoring information' section in the right sidebar. The wrapper should be rendered by datetime-wrapper.html.twig and the datetime element by datetime-form.html.twig.
  • Add a date field to the article content type (select list widget) and navigate to node/add/article. Compare the markup for the date field you added. The wrapper should be rendered by datetime-wrapper.html.twig and the datelist element by datelist-form.html.twig.

#1757550: [Meta] Convert core theme functions to Twig templates

CommentFileSizeAuthor
#76 twig-datetime_theme_render-1963476-76.patch6.62 KBjenlampton
#76 interdiff.txt2.78 KBjenlampton
#71 1963476-71-twig-datetime-theme.patch7.41 KBjoelpittet
#71 interdiff.txt945 bytesjoelpittet
#67 interdiff.txt703 bytesjoelpittet
#67 1963476-67-twig-datetime-theme.patch7.34 KBjoelpittet
#65 twig-datetime-1963476-64.patch7.3 KBjenlampton
#64 twig-image-1939068-67.patch5.44 KBjenlampton
#59 patch-1963476-58.patch5.06 KBadamcowboy
#55 1963476-39.patch6.95 KBsiccababes
#48 datetime-twig.diff2.17 KBkattekrab
#39 1963476-39.patch6.95 KBwidukind
#39 interdiff.txt648 byteswidukind
#38 interdiff.txt650 byteswidukind
#38 1963476-38.patch6.95 KBwidukind
#34 1963476-34-twig-datetime-theme.patch6.98 KBjoelpittet
#34 interdiff.txt3.96 KBjoelpittet
#30 1963476-30.patch6.46 KBwidukind
#30 interdiff.txt1.83 KBwidukind
#28 1963476-28.patch6.49 KBwidukind
#28 interdiff.txt1.41 KBwidukind
#23 1963476-23.patch6.05 KBwidukind
#23 interdiff.txt2.13 KBwidukind
#21 twig-datetime-1963476-21.patch5.83 KBwidukind
#21 interdiff.txt929 byteswidukind
#21 twig-datetime-1963476-21-alt.patch6.08 KBwidukind
#21 interdiff-alt.txt1.21 KBwidukind
#20 twig-datetime-1963476-20.patch5.82 KBwidukind
#20 interdiff.txt2.16 KBwidukind
#20 twig-datetime-1963476-20-alt.patch6.06 KBwidukind
#20 interdiff-alt.txt1.7 KBwidukind
#15 interdiff.txt1.35 KBwidukind
#15 twig-datetime-1963476-15.patch6.01 KBwidukind
#13 interdiff.txt3.57 KBwidukind
#13 twig-datetime-1963476-13.patch6 KBwidukind
#8 interdiff.txt597 bytestlattimore
#8 interdiff.txt597 bytestlattimore
#8 twig-datetime-1963476-8.patch5.56 KBtlattimore
#7 twig-datetime-1963476-7.patch5.55 KBtlattimore
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tlattimore’s picture

Assigned: Unassigned » tlattimore

I'll take a stab at this.

star-szr’s picture

Awesome, thanks @tlattimore. If you get stuck come on by #drupal-twig on IRC :)

star-szr’s picture

Issue tags: +Needs manual testing

Tagging.

star-szr’s picture

Any news @tlattimore, or can you share a partial patch?

tlattimore’s picture

I have a working patch. But still need to do some cleanup. Hope to post it later today.

tlattimore’s picture

Assigned: tlattimore » Unassigned

It looks like I may not be able to get this done so I am going to un-assign myself.

tlattimore’s picture

Status: Active » Needs review
FileSize
5.55 KB

Here is my 1st at converting datetime module to twig.

tlattimore’s picture

FileSize
5.56 KB
597 bytes
597 bytes

This patch removes brackets around title in datetime-wrapper. Still wrestling with php habits..

star-szr’s picture

Thank you very much @tlattimore! I will review this tonight unless someone else gets to it before me.

widukind’s picture

Assigned: Unassigned » widukind
widukind’s picture

Status: Needs review » Needs work

This holds up, good work @tlattimore.

A few minor tweaks may still be beneficial:

1.

 $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
  if (!empty($element['#title'])) {
    $variables['title'] = t('!title!required', array('!title' => $element['#title'], '!required' => $required)) ;
  }

- convert this call to theme() into a renderable.
- call t() in the template.

2. wrap content of twig templates into {% spaceless %} tags.

working on it...

star-szr’s picture

Indeed, at a glance this looks very good!

+++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
@@ -0,0 +1,25 @@
+ * - content: The form element to be output, usually a
+ * datelist, or datetime.

Minor doc nitpick - this wraps early and is not indented.

@widukind - I don't see any reason why {% spaceless %} is needed here, unless I'm missing something :)

widukind’s picture

Status: Needs work » Needs review
FileSize
6 KB
3.57 KB

@Cottser,
{% spaceless %} is not needed - just thought I throw it in there for a more compact output. On second thought, the extra function call is probably not worth it. So thanks for questioning this.

Anyway, here's another patch addressing #11 (sans whitespace removal) and #12.

On a related note, I was not too stoked on the twig syntax for passing an assoc. array as function argument after I moved the translation call into the template

{{ '!title'|t({ '!title': title }) }}

IMO, this would be much easier to read in PHP code.

Is there a guideline on making these translation calls, template vs theme_preprocess function?
So far, I've been going by what I've seen, which is calling t() from within the template.

Thanks!

star-szr’s picture

Status: Needs review » Needs work

@widukind - I agree it's not the prettiest syntax, normally you could use {% set %} to create the array first then pass it to the t filter; unfortunately we currently have a bug around that, see #1916834: Twig implementation: passing array to set tag creates a TwigReference object.

As for calling t() in the template vs. preprocess, that is explained in http://drupal.org/node/1920746#utility and we've decided template is the way to go.

Changes are looking good at a glance, this needs a slight tweak:

+++ b/core/modules/datetime/datetime.moduleundefined
@@ -380,10 +386,17 @@ function template_preprocess_datetime_wrapper(&$variables) {
-  $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
+  $required = '';
+  if (!empty($element['#required'])) {
+    $required = array(
+      '#theme' => 'form_required_marker',
+      '#element' => $element,
+    );
+  }
+  $variables['required'] = $required;

$required should be initialized as an array. Previously $required was always a string but we are converting to a render array so the variable should always be an array so we're not mixing datatypes.

widukind’s picture

@Cottser, thanks for the quick answer.

widukind’s picture

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

Status: Needs review » Needs work

Thanks for keeping this one moving! :) I had a chance to look over the latest patch as a whole, here's some more feedback.

  1. +++ b/core/modules/datetime/datetime.moduleundefined
    @@ -361,27 +366,40 @@ function theme_datelist_form($variables) {
       // If the element is required, a required marker is appended to the label.
    -  $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
    +  $required = array();
    +  if (!empty($element['#required'])) {
    +    $required = array(
    +      '#theme' => 'form_required_marker',
    +      '#element' => $element,
    +    );
    +  }
    +  $variables['required'] = $required;
     
       if (!empty($element['#title'])) {
    -    $output .= '<h4 class="label">' . t('!title!required', array('!title' => $element['#title'], '!required' => $required)) . '</h4>';
    +    $variables['title'] = $element['#title'];
    
    +++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
    @@ -0,0 +1,27 @@
    +    {{ '!title'|t({ '!title': title }) }}{{ required }}
    

    I hadn't looked at what was being removed in the preprocess here, namely what the previous t() string was. This is a case where we currently can't do render arrays in the preprocess.

    We don't want to change what we are passing to t(), so we should still be passing !title!required to t(). I think we can just use a theme() call in preprocess to create the string for 'required' to be added to the t filter already in the template.

    Like this:

    {{ '!title!required'|t({ '!title': title, '!required': required }) }}
    
  2. +++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
    @@ -0,0 +1,27 @@
    + * - content: The form element to be output, usually a
    + *   datelist, or datetime.
    

    This is indented correctly now, but wraps early. Comments should be as long as possible within the 80 character limit per http://drupal.org/node/1354#drupal.

  3. +++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
    @@ -0,0 +1,27 @@
    + * - required: A renderable required marker if the form element is required,
    + *   otherwise an empty array.
    

    Instead of talking about 'renderable' and 'empty array' here (see http://drupal.org/node/1823416#datatypes) I suggest something like this (especially because as in #1 I think it will need to be a string for now):

    - required: (optional) A required marker indicating that the form element is required.

star-szr’s picture

(double post, carry on)

star-szr’s picture

And one more tiny thing…

+++ b/core/modules/datetime/datetime.moduleundefined
@@ -334,11 +336,14 @@ function theme_datetime_form($variables) {
+ * Prepares variables date selection form templates.

"Prepares variables *for*…" per #1913208: [policy] Standardize template preprocess function documentation.

widukind’s picture

Status: Needs work » Needs review
FileSize
1.7 KB
6.06 KB
2.16 KB
5.82 KB

Please see attached patch and interdiff for the changes requested in #17-19.

I also attached an alternative implementation that restores the original translation value but also removes the need to theme the marker within the preprocess function (see -alt files).

widukind’s picture

two more minor tweaks:

1. labeled "required" template variable as optional (as requested in comment #17)

+++ b/core/modules/datetime/templates/datetime-wrapper.html.twig
@@ -7,7 +7,7 @@
  * - content: The form element to be output, usually a datelist, or datetime.
  * - title: The title of the form element.
  * - attributes: Remaining HTML attributes for the form wrapper.
- * - required: A required marker indicating that the form element is required.
+ * - required: (optional) A required marker indicating that the form element is required.

2. in the alt. implementation, i moved the temp. variable assignment/required-rendering inside the if statement.

+++ b/core/modules/datetime/templates/datetime-wrapper.html.twig
@@ -15,8 +15,11 @@
  * @ingroup themeable
  */
 #}
-{% set required_rendered %}{{ required }}{% endset %}
+
 {% if title %}
+  {%- set required_rendered -%}
+    {{ required }}
+  {%- endset -%}
   <h4 class="label">
     {{ '!title!required'|t({ '!title': title, '!required': required_rendered }) }}
   </h4>
widukind’s picture

Issue summary: View changes

Add conversion summary table

star-szr’s picture

Status: Needs review » Needs work

Thanks @widukind, and sorry for the delay in getting back to this. I'm not sure in this case that we're gaining much from the alternative implementation, I vote for now that we either keep the theme() call in the preprocess or convert to a render array and then drupal_render() it. I think the theme function should be fine for now though.

I'll come back for a proper review, but in the meantime there's a couple small coding standards things that can be fixed up:

+++ b/core/modules/datetime/datetime.moduleundefined
@@ -321,7 +323,7 @@ function datetime_date_default_time($date) {
  * @ingroup themeable

@@ -348,7 +353,7 @@ function theme_datetime_form($variables) {
  * @ingroup themeable

@@ -361,27 +366,34 @@ function theme_datelist_form($variables) {
  * @ingroup themeable

We should remove these @ingroup themeable from the preprocess functions per #1913208: [policy] Standardize template preprocess function documentation.

+++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
@@ -0,0 +1,25 @@
+ * - required: (optional) A required marker indicating that the form element is required.

This comment should be wrapped at 80 characters per http://drupal.org/node/1354#drupal.

star-szr’s picture

Issue summary: View changes

Update conversion table

widukind’s picture

Status: Needs work » Needs review
FileSize
2.13 KB
6.05 KB
jwilson3’s picture

+++ b/core/modules/datetime/datetime.moduleundefined
@@ -307,10 +310,9 @@ function datetime_date_default_time($date) {
- * Returns HTML for a HTML5-compatible #datetime form element.
+ * Prepares variables for #datetime form element templates.
...
- * Wrapper around the date element type which creates a date and a time
- * component for a date.

@@ -361,27 +363,32 @@ function theme_datelist_form($variables) {
- * Returns HTML for a datetime form element.
+ * Prepares variables for datetime form element templates.

I'm not entirely sure the documentation was originally correct, because theme_datetime_form mentioned "wrapper" in its docblock, whereas theme_datetime_wrapper() ironically did not. But maybe it makes sense to not lose this comment line talking about "Wrapper around date element" which would help to distinguish and clarify the difference between the two preprocess comments, which in the current patch only differ by the presence of a '#' in front of the word datetime, which isn't very clear at all.

jwilson3’s picture

Status: Needs review » Needs work
widukind’s picture

Assigned: widukind » Unassigned
widukind’s picture

Assigned: Unassigned » widukind
widukind’s picture

Status: Needs work » Needs review
FileSize
1.41 KB
6.49 KB

Alright. I salvaged the previously removed "wrapper" code comment and applied it to new comments. Hopefully this will provide more clarity on what these functions all are about.
I also changed any reference to the "#datetime" form element into "datetime" in the code comments throughout the script for consistency reasons.
Please review again, thanks!

widukind’s picture

Issue summary: View changes

Update remaining

star-szr’s picture

Status: Needs review » Needs work

Thanks @widukind!

I compared markup on node/add/article and it looks like we have an extra wrapper div - <div class="datetime-wrapper">. It doesn't look like theme_datetime_wrapper() actually adds a div, it just prefixes an <h4> if there is a title to be printed. We'll need to update docs to match this as well (i.e. remove 'attributes' from datetime-wrapper.html.twig, and possibly other updates?).

Manual testing steps added to the summary, and here is a docs review:

  1. +++ b/core/modules/datetime/datetime.moduleundefined
    @@ -310,7 +310,9 @@ function datetime_date_default_time($date) {
    + * Prepares variables for datetime form element templates.
    + * The datetime form element serves as a wrapper around the date element type,
    + * which creates a date and a time component for a date.
    

    There needs to be a blank line after the summary line per http://drupal.org/node/1354#functions.

  2. +++ b/core/modules/datetime/datetime.moduleundefined
    @@ -368,7 +370,7 @@ function template_preprocess_datelist_form(&$variables) {
    - * Prepares variables for datetime form element templates.
    + * Prepares variables for wrapper templates around the datetime form element.
    

    What about something like 'Prepares variables for datetime form wrapper templates.'? Less wordy and ends in 'templates'.

  3. +++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
    @@ -0,0 +1,26 @@
    + * Default theme implementation for datetime form wrapper.
    

    "for a datetime…" or maybe "of a datetime…"?

  4. +++ b/core/modules/datetime/templates/datetime-wrapper.html.twigundefined
    @@ -0,0 +1,26 @@
    + * - required: (optional) A required marker indicating that the form element is
    + *   required.
    

    Too many 'required' I think :) I suggest removing the first 'required' in the variable description, "A marker indicating…"

  5. +++ b/core/modules/datetime/datetime.moduleundefined
    @@ -310,7 +310,9 @@ function datetime_date_default_time($date) {
    + * Prepares variables for datetime form element templates.
    + * The datetime form element serves as a wrapper around the date element type,
    + * which creates a date and a time component for a date.
    

    There needs to be a blank line after the summary line per http://drupal.org/node/1354#functions.

  6. +++ b/core/modules/datetime/datetime.moduleundefined
    @@ -368,7 +370,7 @@ function template_preprocess_datelist_form(&$variables) {
    - * Prepares variables for datetime form element templates.
    + * Prepares variables for wrapper templates around the datetime form element.
    

    What about just 'Prepares variables for datetime wrapper templates.'?

widukind’s picture

FileSize
1.83 KB
6.46 KB

Thanks @Cottser.
Improved the code comments as outlined above.

widukind’s picture

Status: Needs work » Needs review
c4rl’s picture

Title: Convert datetime module to Twig » datetime.module - Convert theme_ functions to Twig

Per #1757550-44: [Meta] Convert core theme functions to Twig templates, retitling to indicate this issue applies to theme_ functions, which are lower in priority than PHPTemplate conversion issues.

intergalactic overlords’s picture

Status: Needs review » Needs work

On node/add/article, the div-wrapper is still there. It doesn't have a class anymore though.

joelpittet’s picture

Assigned: widukind » Unassigned
Status: Needs work » Needs review
FileSize
3.96 KB
6.98 KB

Removed drupal_render_children as per #1920886 and new Attribute() as per #1982024

StryKaizer’s picture

Patch #34 still adds a div-wrapper on node/add/article, without a class

intergalactic overlords’s picture

Status: Needs review » Needs work

Indeed, div-wrapper is still there.

widukind’s picture

Assigned: Unassigned » widukind
widukind’s picture

Status: Needs work » Needs review
FileSize
6.95 KB
650 bytes

removed the extraneous div.

widukind’s picture

FileSize
648 bytes
6.95 KB

minor tweak to the patch in comment #38 - removed unwanted blank line. otherwise this is identical.

intergalactic overlords’s picture

Manually checked, the html output is good. Ready for profiling.

StryKaizer’s picture

Issue tags: -needs profiling

patch in #39 passed my manual testing and daisydiff. Testscenario used as described in first post.

StryKaizer’s picture

Issue tags: +needs profiling

Did not profile, sorry, my mistake ;)

widukind’s picture

Assigned: widukind » Unassigned
widukind’s picture

Assigned: Unassigned » widukind

attempting to profile...

epersonae2’s picture

#39: 1963476-39.patch queued for re-testing.

kattekrab’s picture

Manually testing this one now.

widukind’s picture

Assigned: widukind » Unassigned

i give up on profiling, can't seem to get any consistency in the baseline from xhprof at all.

someone else with a more stable environment please try, thanks.

kattekrab’s picture

Assigned: Unassigned » widukind
FileSize
2.17 KB

HTML output matches.

diff attached.

kattekrab’s picture

Assigned: widukind » Unassigned

save clash... unassigning widukind again.

Still needs profiling. Not something I'm going to try and attempt on a crusty little netbook.

carsonevans’s picture

I will attempt to profile now

carsonevans’s picture

Issue tags: -needs profiling

bbranches 519ff5087988b 1963476-39.patch
Warning: Must specify directory location for XHProf runs. Trying /tmp as default. You can either pass the directory location as an argument to the constructor for XHProfRuns_Default() or set xhprof.output_dir ini param.
=== 8.x..8.x compared (519ff5087988b..519ff54646296):

ct : 40,386|40,386|0|0.0%
wt : 447,276|447,067|-209|-0.0%
cpu : 432,313|432,833|520|0.1%
mu : 40,759,592|40,759,592|0|0.0%
pmu : 40,892,112|40,892,112|0|0.0%

Profiler output

Warning: Must specify directory location for XHProf runs. Trying /tmp as default. You can either pass the directory location as an argument to the constructor for XHProfRuns_Default() or set xhprof.output_dir ini param.
=== 8.x..1963476-39.patch compared (519ff5087988b..519ff588c96fd):

ct : 40,386|40,386|0|0.0%
wt : 447,276|448,273|997|0.2%
cpu : 432,313|431,743|-570|-0.1%
mu : 40,759,592|40,758,456|-1,136|-0.0%
pmu : 40,892,112|40,890,624|-1,488|-0.0%

Profiler output

---
ct = function calls, wt = wall time, cpu = cpu time used, mu = memory usage, pmu = peak memory usage

Status: Needs review » Needs work

The last submitted patch, datetime-twig.diff, failed testing.

carsonevans’s picture

=== 8.x..8.x compared (51a0079b7e32a..51a008005daf0):

ct : 76,176|76,176|0|0.0%
wt : 659,364|661,572|2,208|0.3%
cpu : 632,898|633,364|466|0.1%
mu : 41,026,312|41,026,312|0|0.0%
pmu : 41,187,832|41,187,832|0|0.0%

Profiler output

=== 8.x..1963476-39.patch compared (51a0079b7e32a..51a0086001e4c):

ct : 76,176|76,491|315|0.4%
wt : 659,364|664,510|5,146|0.8%
cpu : 632,898|636,615|3,717|0.6%
mu : 41,026,312|41,139,800|113,488|0.3%
pmu : 41,187,832|41,301,000|113,168|0.3%

Profiler output

---
ct = function calls, wt = wall time, cpu = cpu time used, mu = memory usage, pmu = peak memory usage

carsonevans’s picture

Issue summary: View changes

Add testing steps to summary

gnuget’s picture

Status: Needs work » Needs review

Seems to the correct patch is #39 so, i'm going to mark this back to "needs review"

gnuget’s picture

Issue summary: View changes

Updated issue summary.

siccababes’s picture

FileSize
6.95 KB

The patch needed a re-roll. I took a stab at it. Hopefully this will do the trick.

Status: Needs review » Needs work

The last submitted patch, 1963476-39.patch, failed testing.

siccababes’s picture

Issue tags: +Needs reroll
pwieck’s picture

- Reroll conflict - Somethings missing here, this doesn't look right.

In file core/modules/datetime/datetime.module

  if (!empty($element['#title'])) {
    $variables['title'] = $element['#title'];
  }    

<<<<<<< HEAD
  if (!empty($element['#description'])) {
    $output .= '<div class="description">' . $element['#description'] . '</div>';
  }

  return $output;
=======
  $variables['content'] = $element['#children'];
>>>>>>> Applying patch from https://drupal.org/node/1963476#comment-7441282
}

/**
 * Expands a datetime element type into date and/or time elements.
adamcowboy’s picture

Status: Needs work » Needs review
FileSize
5.06 KB

Re-rolling again.

Status: Needs review » Needs work

The last submitted patch, patch-1963476-58.patch, failed testing.

pwieck’s picture

Please see #58 on re-roll issue

star-szr’s picture

Issue tags: -Needs reroll

Thanks for the rerolls folks :) removing needs reroll tag for now.

I looked at this with @pwieck today in IRC.

@siccababes - the patch uploaded was the same as the one in #39 - wrong file maybe?

@adamcowboy - The reroll in #59 is pretty close! The main issue is that the three Twig templates are missing (apply the before reroll patch with --index to prevent that as shown in the reroll instructions).

+++ b/core/modules/datetime/datetime.moduleundefined
@@ -317,85 +322,81 @@ function datetime_date_default_time($date) {
+function template_preprocess_datelist_form(&$variables) {
   $element = $variables['element'];
-
-  $attributes = array();
   if (isset($element['#id'])) {
-    $attributes['id'] = $element['#id'];
+	$variables['attributes']['id'] = $element['#id'];
   }
   if (!empty($element['#attributes']['class'])) {
-    $attributes['class'] = (array) $element['#attributes']['class'];
+	$variables['attributes']['class'] = (array) $element['#attributes']['class'];
   }
-  $attributes['class'][] = 'container-inline';
 
-  return '<div' . new Attribute($attributes) . '>' . drupal_render_children($element) . '</div>';
+	$variables['attributes']['class'][] = 'container-inline';
+	
+	 $variables['content'] = $element;
 }

Some tabs snuck in so those will need to be removed per http://drupal.org/coding-standards#indenting.

Conflict pointed out in #58:

+++ b/core/modules/datetime/datetime.moduleundefined
@@ -317,85 +322,81 @@ function datetime_date_default_time($date) {
-  if (!empty($element['#description'])) {
-    $output .= '<div class="description">' . $element['#description'] . '</div>';
-  }

We should be keeping this (determined via git blame that it was added via #2006484-25: Remove dependency on datetime from node). We can convert it to a 'description' variable and then add it to the Twig template. The markup <div class="description"></div>can be moved to the Twig template. We'll probably want to add another {% if %} to the datetime-Twig template similar to how the title is handled.

We may be able to simplify the handling of the required marker in template_preprocess_datetime_wrapper() but let's get tests passing first :)

So if someone wants to clean up the reroll in #59 or a do a fresh one that would be awesome!

jenlampton’s picture

Assigned: Unassigned » jenlampton

on it

jenlampton’s picture

Assigned: jenlampton » Unassigned
Status: Needs work » Needs review
FileSize
5.44 KB

rerolled, added description variable, removed @see template_preprocess. Needs another review :)

jenlampton’s picture

no no, that's not even the right patch...

Status: Needs review » Needs work

The last submitted patch, twig-datetime-1963476-64.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
7.34 KB
703 bytes

The required variable needs to be defined, so I set it to NULL.

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

The last submitted patch, 1963476-67-twig-datetime-theme.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review

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

The last submitted patch, 1963476-67-twig-datetime-theme.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
945 bytes
7.41 KB

Seems disabled attribute is getting passed to the wrapper attributes, so I had to add back in the wrapper attributes array init.

azinoman’s picture

Status: Needs work » Reviewed & tested by the community

Status: Needs review » Needs work

The last submitted patch, 1963476-71-twig-datetime-theme.patch, failed testing.

sbudker1’s picture

It looks like datetime-wrapper.html.twig and datelist-form.html.twig. are both being used in both the "Authoring Information" and the "Date field" while datetime-form.html.twig. does not seem to be used in either. What if we removed the datetime-form.html.twig.? The datetime-form.html.twig. is also identical to the datelist-form.html.twig.

sbudker1’s picture

Status: Reviewed & tested by the community » Needs review
jenlampton’s picture

Status: Needs review » Needs work
FileSize
2.78 KB
6.62 KB

Good idea, but I'd prefer to remove datelist-form just for naming reasons. Taking a stab at that now.

jenlampton’s picture

Status: Needs work » Needs review

oh yeah, status change.

sbudker1’s picture

Status: Needs review » Needs work

dibs!

jenlampton’s picture

Status: Needs work » Needs review

reviewing, I assume ;)

sbudker1’s picture

Status: Needs review » Reviewed & tested by the community

Patch worked! It succeeded testing with the steps below and overall no issues or problems were evident.

Testing steps

-Navigate to node/add/article, compare the markup for the 'Authored on' field in the 'Authoring information' section in the right sidebar. The wrapper should be rendered by datetime-wrapper.html.twig and the datetime element by datetime-form.html.twig.
-Add a date field to the article content type (select list widget) and navigate to node/add/article. Compare the markup for the date field you added. The wrapper should be rendered by datetime-wrapper.html.twig and the datelist element by datelist-form.html.twig.

alexpott’s picture

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

Can we get a new profile as this patch has changed since it was done...

jenlampton’s picture

Status: Needs work » Needs review

marking needs review, since it will need a profiling review too after that gets done, but the patch doesn't currently need work.

joelpittet’s picture

Scenario

Theme: stark
permissions: anonymous can "Administer content" and "Bypass content access control "
url: /node/add/article
Added a date field to the article type.

=== 8.x..8.x compared (51e30f7568a45..51e30feb01694):

ct  : 69,016|69,016|0|0.0%
wt  : 528,422|533,177|4,755|0.9%
cpu : 470,454|470,747|293|0.1%
mu  : 34,196,832|34,196,832|0|0.0%
pmu : 34,335,968|34,335,968|0|0.0%

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

=== 8.x..1963476-twig-datetime-theme compared (51e30f7568a45..51e3103d95a81):

ct  : 69,016|69,328|312|0.5%
wt  : 528,422|534,843|6,421|1.2%
cpu : 470,454|470,926|472|0.1%
mu  : 34,196,832|34,300,248|103,416|0.3%
pmu : 34,335,968|34,441,680|105,712|0.3%

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

kattekrab’s picture

Thanks @joelpittet for running the profile!

So - is that within acceptable limits?

joelpittet’s picture

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

@kattekrab I'd say yes, it's 0.3% (1.6ms) difference on the Wall Time between the two runs.

And it removes a theme_ function!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 15d3012 and pushed to 8.x. Thanks!

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

Anonymous’s picture

Issue summary: View changes

Correct case in commit message