Problem/Motivation

When creating a view with the page-type of Feeds, RSS Feed, and fields (vs content), the date field adds a <time> tag:
<pubDate><time datetime="2023-08-10T13:43:13-07:00" class="datetime">Thu, 10 Aug 2023 13:43:13 -0700</time></pubDate>

I've chosen "major" as this broke a bunch of our feeds, and I'd imagine it does the same for many other folks.

This also causes Planet Drupal to sometimes be flooded with a lot of old items from a feed, after the site got updated to Drupal 10, see #3399284: Prevent flooding of feeds such as Drupal Planet with old blog posts. From release Drupal 10.2.1 this should be fixed.

Steps to reproduce

  • Create a view
  • Create a Feed
  • Add the appropriate fields (I chose Title, Body, Authored By, Authored On, Link to Content, and UUID)
  • Set the format to RSS Feed
  • Set Show to Fields
  • Map the Field Settings to point to the appropriate fields
  • The feed will have an added <time> as illustrated above.

Thanks!

CommentFileSizeAuthor
#7 Screenshot 2023-10-25 at 11.43.23 AM.png275.46 KBdanstorm

Issue fork drupal-3383219

Command icon 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

greatmatter created an issue. See original summary.

greatmatter’s picture

In case anyone lands on this, our workaround is to enable "rewrite results" for the field, and use twig:
{{ created__value|date('D, d M Y H:i:s O') }}
This "fixes" it.

lendude’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for posting your issue and workaround, I have some questions that might help get some work done on this.

this broke a bunch of our feeds

When did this break a bunch of feeds, was this after an update? If so, which one? It might help track down what changed this. Or is this just an issue when creating any new Feed that doesn't align with how the feed should be formatted?

Also, I'm wondering, is this just using core/modules/system/templates/time.html.twig for rendering? And if so, is this a problem in Views or somewhere else?

greatmatter’s picture

@lendude - It's hard to say, because I was notified by a volunteer. If I had to guess, it was around the time we updated the site to Drupal 10, but I can't be sure.

powysm’s picture

I am seeing this on my REST Export feeds after updating Drupal from 9.5.11 to 10.1.4.
I am surprised this is not better documented somewhere, if it is I haven't found it.

I worked around this by checking "Strip HTML tags" and "Remove whitespace" under "rewrite results".

pminf’s picture

We updated Drupal from 9.5.10 to 10.1.4 and didn't had this issue before.

@lendude The template doesn't seem to matter. The markup of all our field based feeds changed from

<pubDate>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/views/views-view-field.html.twig' -->
Tue, 26 Sep 2023 12:55:17 +0200
<!-- END OUTPUT from 'core/themes/stable/templates/views/views-view-field.html.twig' -->

</pubDate>

to

  <pubDate>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'themes/contrib/stable/templates/views/views-view-field.html.twig' -->


<!-- THEME DEBUG -->
<!-- THEME HOOK: 'time' -->
<!-- BEGIN OUTPUT from 'themes/contrib/stable/templates/field/time.html.twig' -->
<time datetime="2023-09-26T12:55:17+02:00">Tue, 26 Sep 2023 12:55:17 +0200</time>

<!-- END OUTPUT from 'themes/contrib/stable/templates/field/time.html.twig' -->


<!-- END OUTPUT from 'themes/contrib/stable/templates/views/views-view-field.html.twig' -->

</pubDate>

As you can see we are using a theme based on contrib stable. But the issue is also present when using the current stark theme with core/modules/system/templates/time.html.twig:

  <pubDate>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->


<!-- THEME DEBUG -->
<!-- THEME HOOK: 'time' -->
<!-- BEGIN OUTPUT from 'core/modules/system/templates/time.html.twig' -->
<time datetime="2023-09-26T12:55:17+02:00">Tue, 26 Sep 2023 12:55:17 +0200</time>

<!-- END OUTPUT from 'core/modules/system/templates/time.html.twig' -->


<!-- END OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->

</pubDate>

I can confirm the workaround from #5:

  <pubDate>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'themes/contrib/stable/templates/views/views-view-field.html.twig' -->



Tue, 26 Sep 2023 12:55:17 +0200


<!-- END OUTPUT from 'themes/contrib/stable/templates/views/views-view-field.html.twig' -->

</pubDate>

(Ignore the whitespaces. They are not present if theme debug is disabled.)

danstorm’s picture

StatusFileSize
new275.46 KB

We are currently experiencing this in all of our Views Rest Exports (the ones with time fields, anyway) after upgrading from Drupal 9.5.11 to Drupal 10.1.5 and running `drush updb`. Looks like there is an update in the list that is likely the cause (highlighted text in attached screenshot).

#5 solves the issue, but since we are running headless, this affects a lot of our endpoints and is unfortunately causing a heck of a lift between identifying and manually editing all of the affected views

papagrande’s picture

Status: Postponed (maintainer needs more info) » Active
Related issues: +#2921810: Allow TimestampFormatter to show as a fully cacheable time difference with JS

Same problem for me--updated to D10 and RSS feeds break. And the workaround in #5 fixes it.

Based on git blame it looks like the change was introduced in https://www.drupal.org/project/drupal/issues/2921810. Perhaps the Views RSS row formatter needs tweaking to exclude the <time> element.

lendude’s picture

#8 seems to point to the right issue, looking at the MR, this change was needed there:

    $this->assertEquals($date_formatter->format($this->testUsers[0]->getCreatedTime(), 'custom', 'Y'), $executable->getStyle()->getField(0, 'created'));

to

    $this->assertEquals($date_formatter->format($this->testUsers[0]->getCreatedTime(), 'custom', 'Y'), trim(strip_tags($executable->getStyle()->getField(0, 'created'))));

Which would indicate that new things got added to the output there.

heikkiy’s picture

We encountered the same issue in two projects that updated from core 9.5.11 to 10.x. We were able to hotfix this by enabling the Strip HTML tags (strip_tags) and Trim whitespace (trim_whitespace) options in the view for example for the Created field.

ressa’s picture

@Dave Reid pointed me to this issue, which explains the occasional flooding of old blog posts on Drupal Planet. It seems to happen after an upgrade from Drupal 9 to Drupal 10.

ressa’s picture

Issue summary: View changes

Marking up <time> as code, since it is invisible otherwise :)

hansfn’s picture

I guess we could apply the "fix" in comment #5 in RssFields::render. The date field doesn't have a formatter without the time element so we need to strip to get pubDate as plain text.

drumm’s picture

Issue tags: +affects drupal.org

lendude’s picture

Version: 10.1.x-dev » 11.x-dev
Status: Active » Needs review

Stripping tags on the pubDate sounds logical, that shouldn't contain HTML

Added that as a fix and added test coverage

heikkiy’s picture

I tested the fix from #16. It seems to fix the problem and I didn't see any extra empty space either in my testing.

Probably makes sense to have a second review also and check the tests attached.

lendude’s picture

The test was showing the reported whitespace, so lets trim that too

lendude’s picture

Added a comment explaining why we are doing this

heikkiy’s picture

Great! I tested it myself the following way:

1. Removed the Strip tags and trim settings mentioned #10.
2. Verified that the time tag was in back in the feed.
3. Applied the patch.
4. Verified that time tag was removed.

I didn't encounter the whitespace issue when checking the actual feed so great that it was catched by the tests. Might have been a browser feature when checking the feed.

I vote this could be marked as RTBC.

papagrande’s picture

Status: Needs review » Reviewed & tested by the community

Looks great! Thanks @Lendude and @HeikkiY.

  • catch committed 2e94575d on 11.x
    Issue #3383219 by Lendude, greatmatter, HeikkiY, PapaGrande, hansfn:...
catch’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!

  • catch committed f7e93f2a on 10.2.x
    Issue #3383219 by Lendude, greatmatter, HeikkiY, PapaGrande, hansfn:...
ressa’s picture

Issue summary: View changes

Thanks everyone! There was another surge of old posts on Drupal Planet today, but from Drupal 10.2.1 it looks like this should be fixed.

Status: Fixed » Closed (fixed)

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