We have a template file named datetime.html.twig in the system module, but it outputs a HTML5 <time> tag, it should be renamed time.html.twig.

This change also helps avoid confusion with '#type' => 'datetime' which outputs a datetime form element.

Files: 
CommentFileSizeAuthor
#45 interdiff.txt740 bytesCottser
#45 2088365-45.patch2.93 KBCottser
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,158 pass(es). View
#42 interdiff.txt801 bytesCharuAg
#42 node-2088365-42.patch5.88 KBCharuAg
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 74,992 pass(es). View
#40 node-2088365-40.patch6.05 KBbradklaver
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,117 pass(es). View
#35 drupal-wrong_name_for_datetime.html_.twig-2088365-35.patch6.18 KBmachostache
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 71,902 pass(es). View
#32 drupal-wrong_name_for_datetime.html_.twig-2088365-32.patch6.09 KBcs_shadow
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,992 pass(es). View
#30 interdiff-28-30.txt288 bytescs_shadow
#30 drupal-wrong_name_for_datetime.html_.twig-2088365-30.patch4.36 KBcs_shadow
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,910 pass(es), 3 fail(s), and 3 exception(s). View
#28 drupal-wrong_name_for_datetime.html_.twig-2088365-28.patch4.36 KBcs_shadow
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,908 pass(es), 3 fail(s), and 3 exception(s). View
#25 datetime.html_.twig-to-time.html_.twig-2088365-25.patch6.04 KBvisabhishek
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,536 pass(es). View
#25 interdiff-2088365-20-25.txt723 bytesvisabhishek
#23 interdiff-2088365-20-23.txt2.89 KBsriharsha.uppuluri
#23 datetime.html_.twig-to-time.html_.twig-2088365-23.patch4.08 KBsriharsha.uppuluri
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,489 pass(es), 3 fail(s), and 3 exception(s). View
#20 datetime.html_.twig-to-time.html_.twig-2088365-20.patch5.38 KBsriharsha.uppuluri
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,545 pass(es). View
#20 interdiff.txt3.23 KBsriharsha.uppuluri
#14 datetime.html_.twig-to-time.html_.twig-2088365-14.patch5.87 KBgrisendo
PASSED: [[SimpleTest]]: [MySQL] 59,914 pass(es). View

Comments

nod_’s picture

Title: wrong name for datetime.html.twig » Wrong name for datetime.html.twig should be time.html.twig
Issue tags: +markup

tag

naveenvalecha’s picture

Taking this one.

naveenvalecha’s picture

Status: Active » Needs review
FileSize
247 bytes
FAILED: [[SimpleTest]]: [MySQL] 58,899 pass(es), 8 fail(s), and 4 exception(s). View

Attached patch for this small change.

naveenvalecha’s picture

Please someone reroll the patch to update the documentation in the twig file.

Status: Needs review » Needs work

The last submitted patch, datetime.html_.twig-to-time.html_.twig-2088365-3.patch, failed testing.

undertext’s picture

Assigned: Unassigned » undertext
undertext’s picture

Does this means that form element must be renamed to 'time' e.g

  $form['some'] = array(
    '#type' => 'datetime',
  );

must be

  $form['some'] = array(
    '#type' => 'time',
  );
nod_’s picture

The form element is a different matter, time tag is not a form element at all. It's just for display.

For form types, see #2088383: Datetime FAPI DX.

Cottser’s picture

To make this change you will need to update drupal_common_theme() as well:

https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/d...

Usually the template name matches up with the theme hook name - so I would suggest updating the theme hook to 'time', so that it is rendered via '#theme' => 'time' rather than '#theme' => 'datetime'.

undertext’s picture

FileSize
2.17 KB
PASSED: [[SimpleTest]]: [MySQL] 58,728 pass(es). View
undertext’s picture

Status: Needs work » Needs review
Cottser’s picture

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

That's great, thanks @undertext! Looks like this needs a reroll now.

We'll also need to update template_preprocess_datetime() to template_preprocess_time() - this is referenced in a @see in the Twig template.

The ideal result here will be a rerolled patch, an interdiff, and then a revised patch. The interdiff will show the differences between the rerolled patch and the revised patch (that updates the preprocess function).

grisendo’s picture

Issue summary: View changes
FileSize
5.44 KB
PASSED: [[SimpleTest]]: [MySQL] 59,386 pass(es). View

Re-rolled

grisendo’s picture

FileSize
1.15 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch datetime.html_.twig-to-time.html_.twig-2088365-13_14.interdiff.patch. Unable to apply patch. See the log in the details link for more information. View
5.87 KB
PASSED: [[SimpleTest]]: [MySQL] 59,914 pass(es). View

And now the template_preprocess_time change and interdiff

grisendo’s picture

Assigned: undertext » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll

Status: Needs review » Needs work
herom’s picture

Status: Needs work » Needs review

the patch is green, so... needs review.

grisendo’s picture

Sorry, I forgot to set interdiff extension to .txt to avoid testing it :(

LinL’s picture

Status: Needs review » Needs work

Patch no longer applies.

sriharsha.uppuluri’s picture

Assigned: Unassigned » sriharsha.uppuluri
Status: Needs work » Needs review
FileSize
3.23 KB
5.38 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,545 pass(es). View

Uploading the rerolled patch.

brantwynn’s picture

Cottser’s picture

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

Thanks @sriharsha.uppuluri!

We need to rename template_preprocess_datetime() like in #14.

sriharsha.uppuluri’s picture

Status: Needs work » Needs review
FileSize
4.08 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,489 pass(es), 3 fail(s), and 3 exception(s). View
2.89 KB

Thanks @Cottser

Renamed template_preprocess_datetime() like in #14.

Status: Needs review » Needs work

The last submitted patch, 23: datetime.html_.twig-to-time.html_.twig-2088365-23.patch, failed testing.

visabhishek’s picture

Status: Needs work » Needs review
FileSize
723 bytes
6.04 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,536 pass(es). View

i am updating patch #20 based on #22 comments.

sriharsha.uppuluri’s picture

Assigned: sriharsha.uppuluri » Unassigned
Cottser’s picture

Status: Needs review » Needs work

Looking good, one minor tweak needed then this should be ready to go:

+++ b/core/includes/theme.inc
@@ -997,7 +997,7 @@ function theme_disable($theme_list) {
- * Preprocess variables for theme_datetime().
+ * Preprocess variables for theme_time().

While we're updating this it should follow our newer documentation standards for preprocess functions:

Preprocess function documentation standards

…and in particular it shouldn't refer to theme_time() because that doesn't exist :)

cs_shadow’s picture

Status: Needs work » Needs review
FileSize
4.36 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,908 pass(es), 3 fail(s), and 3 exception(s). View

Changed the patch in #25 to incorporate changes suggested in #27.

The doc block now looks like:

/**
 * Preprocess variables for time templates.
 *
 * Default template: time.html.twig.
 *
 * @param array $variables
Cottser’s picture

Thanks @cs_shadow!

Interdiff next time, please! And "Preprocess" should be "Prepares" according to the documentation standards.

cs_shadow’s picture

FileSize
4.36 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,910 pass(es), 3 fail(s), and 3 exception(s). View
288 bytes

Changed the patch as suggested in #29. Attaching interdiff.

The last submitted patch, 28: drupal-wrong_name_for_datetime.html_.twig-2088365-28.patch, failed testing.

cs_shadow’s picture

FileSize
6.09 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 67,992 pass(es). View

Trying to fix the errors in #28.

The last submitted patch, 30: drupal-wrong_name_for_datetime.html_.twig-2088365-30.patch, failed testing.

machostache’s picture

Assigned: Unassigned » machostache

I'm at the Austin core mentoring spring and I am going to reroll the latest patch.

machostache’s picture

FileSize
6.18 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 71,902 pass(es). View

Patch #32 failed to apply due to renaming of core/modules/datetime/lib directory to core/modules/datetime/src.

Tried to create interdiff but could not reroll patch due to corrupt patch error when applying.

Recreated patch to match latest core version.

selfuntitled’s picture

Status: Needs review » Reviewed & tested by the community

At Drupalcon Austin - just tested patch in #35. Applies cleanly, looks to remove all references to datetime.html.twig updated to reviewed and tested.

catch’s picture

Status: Reviewed & tested by the community » Needs review

Not sure about this, while the HTML5 element is called 'time', the thing being formatted is a datetime (and the HTML5 spec allows a datetime attribute for that element). The whole point of the template is to allow for changing the markup, which could include using a different element.

nod_’s picture

We do have select.html.twig, table.html.twig, textarea.html.twig, form.html.twig,fieldset.html.twig, details.html.twig, html.html.twig and also image.html.twig.

( edit ) since template deal with HTML, it should be pretty clear to everyone it's the HTML meaning of time that is used.

joelpittet’s picture

Issue tags: +Needs change record

@catch, I was thinking along the same lines as you, it's such a blurry line here. Also very minor, I'd recommend making this change.

@_nod, I so wish we weren't so granular in the templates and let the templates live at a more component level or view mode level. That, or we may as well create a template for the whole html spec of tags. And the more granular the slower on the io and rendering... sorry I had to rant because I see these single tag templates with very little context and wonder how anybody builds a site in a reasonable amount of time with that level of templates. Like trying to build a fence and all you have is toothpicks. Oh and sorry because you may not be the right person to rant in the direction...
but seeing them listed out just made me go "argh".

This may need a small change record though?

bradklaver’s picture

Assigned: machostache » Unassigned
FileSize
6.05 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,117 pass(es). View

Re-rollling machostache 's patch in comment #35.

Cottser’s picture

Status: Needs review » Needs work

Thanks @bradklaver!

This wasn't introduced by the reroll, but there's something broken. This also means we have little to no test coverage for the aggregator_summary_item theme hook (I hacked core to even get it to be used). The tests can probably be added in another issue, no need to hold this one up.

+++ b/core/modules/aggregator/aggregator.theme.inc
@@ -118,7 +118,7 @@ function template_preprocess_aggregator_summary_item(&$variables) {
   $variables['age'] = array(
     '#theme' => 'datetime',
     '#attributes' => array(
-      'datetime' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'),
+      'time' => format_date($item->getPostedTime(), 'html_datetime', '', 'UTC'),
       'class' => array('feed-item-age',),
     ),
     '#text' => t('%age old', array('%age' => \Drupal::service('date')->formatInterval(REQUEST_TIME - $item->getPostedTime()))),

'#theme' should be changed to 'time' here and the attribute should remain as 'datetime'. See http://www.brucelawson.co.uk/2012/best-of-time/.

CharuAg’s picture

Status: Needs work » Needs review
FileSize
5.88 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 74,992 pass(es). View
801 bytes

Addressed comment 41.

Cottser’s picture

Issue to add tests created: #2325501: Add test coverage for output of aggregator_summary_item theme hook

This needs a small change record then it can be RTBC.

Cottser’s picture

Assigned: Unassigned » Cottser

Working on the change record.

Cottser’s picture

Assigned: Cottser » Unassigned
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice, -Needs change record +Quick fix
FileSize
2.93 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 75,158 pass(es). View
740 bytes
  • Change record draft is up: https://www.drupal.org/node/2326617
  • Added a note about '#type' => 'datetime' to the issue summary.
  • Making a minor documentation tweak to the patch.

RTBC!

Patch is smaller because I have this in my .gitconfig:

[diff]
	renames = copies
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Good catch.

Committed and pushed to 8.x. Thanks!

  • webchick committed 1b25220 on 8.0.x
    Issue #2088365 by Cottser, CharuAg, bradklaver, machostache, cs_shadow,...

Status: Fixed » Closed (fixed)

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