Make WordPress Core

Opened 4 weeks ago

Last modified 2 weeks ago

#62400 assigned defect (bug)

RSS Block showing date in UTC when pubDate in feed is not

Reported by: kaitohm's profile kaitohm Owned by: pbearne's profile pbearne
Milestone: 6.8 Priority: normal
Severity: normal Version: 6.7
Component: Date/Time Keywords: has-testing-info gutenberg-merge has-patch
Focuses: Cc:

Description

Originally reported in this Japanese support thread.

To reproduce:

  1. Change the site timezone to something other than UTC+0. (Example: UTC+9)
  2. Include an RSS Block to any post.
  3. Add a link to an RSS feed where the pubDate item is not in GMT/UTC. (Example: https://www.mixonline.jp/DesktopModules/MixOnline_Rss/MixOnlinerss.aspx?rssmode=3 where pubDate has a +0900 offset.)
  4. In block settings, turn on Display date.
  5. Both in the editor and the published post, the date will be shown in UTC. (Example: An article with <pubDate>Wed, 13 Nov 2024 04:52:00 +0900</pubDate> in the feed will be shown November 12, 2024. With the site timezone set to UTC+9, I would expect this to say November 13, 2024)

Things I've tested:

Change History (16)

#1 @sainathpoojary
4 weeks ago

Hi @kaitohm,

Welcome to Trac, and thank you for opening this ticket!

I’ve confirmed that I could reproduce the issue on WordPress version 6.7. There seems to be an inconsistency in the date between the editor/front end, and the feed data.

Thanks again for bringing this to attention!

#2 @narenin
4 weeks ago

Hi @kaitohm

I have tried to replicate this issue and I am able to replicate this at my end too.

Environment

WordPress: 6.7-beta1-59152-src
PHP: 8.3.7
Server: nginx/1.25.4
Database: mysqli (Server: 8.3.0 / Client: mysqlnd 8.3.7)
Browser: Chrome 125.0.0.0
OS: macOS
Theme: Twenty Twenty-One Version 2.2
MU Plugins: None activated
Plugins:

Related File : packages/block-library/src/rss/index.php line no. 53,54

Also it looks like this is happening because we are using date_i18n() function in WordPress formats a date according to the locale and the settings defined in WordPress, but it does not automatically adjust the time according to the timezone set in WordPress settings (Settings > General > Timezone). It relies on the get_option( 'timezone_string' ) or get_option( 'gmt_offset' ) to determine the correct time zone. However, the date_i18n() function formats the date based on the server time (which could be in UTC or any other server timezone) unless you explicitly adjust for timezones.

Last edited 4 weeks ago by narenin (previous) (diff)

#3 @narenin
4 weeks ago

  • Keywords has-testing-info added

#4 follow-up: @sainathpoojary
4 weeks ago

Hey @kaitohm,

As this issue is related to Gutenberg, I’ve opened a issue in the Gutenberg repository for further review.

You can track the progress here: https://github.com/WordPress/gutenberg/issues/66970

This ticket was mentioned in Slack in #core-test by oglekler. View the logs.


4 weeks ago

#6 @oglekler
4 weeks ago

  • Keywords gutenberg-merge added

@kirasong please check this as as a candidate to 6.7.1. release.

#7 in reply to: ↑ 4 @kaitohm
4 weeks ago

Replying to sainathpoojary:

Hey @kaitohm,

As this issue is related to Gutenberg, I’ve opened a issue in the Gutenberg repository for further review.

You can track the progress here: https://github.com/WordPress/gutenberg/issues/66970

Thanks!

#8 @Mamaduka
4 weeks ago

Already replied on the Gutenberg issue, but the same problem probably affects the legacy RSS widget - https://github.com/WordPress/wordpress-develop/blob/a27e6a8ecd5279a45e47ef88d048643740d07b5a/src/wp-includes/widgets.php#L1654-L1660.

@kaitohm, can you clarify the expected behavior in the description?

I expect that the RSS block/widget will display dates in the format specified in WP, but the date will be in the origins timezone. Unless I'm missing something, the publishing date shouldn't be relative to the WP configuration.

#9 @kaitohm
4 weeks ago

@kaitohm, can you clarify the expected behavior in the description?

@Mamaduka Did you mean here in Trac, or in the GitHub issue?

Currently, if the feed says <pubDate>Wed, 13 Nov 2024 04:00:00 +0900</pubDate>, then regardless of site timezone, the block shows November 12th.

What should happen is, if the feed says <pubDate>Wed, 13 Nov 2024 04:00:00 +0900</pubDate>, then

  • if the site timezone is set to UTC+5, UTC+6, UTC+7..., then the block should show November 13th.
  • if the site timezone is set to UTC+4, UTC+3, UTC+2..., then the block should show November 12th.

As another example, if the feed says <pubDate>Wed, 13 Nov 2024 04:00:00 GMT</pubDate>, then

  • if the site timezone is set to UTC-4, UTC-3, UTC-2..., then the block should show November 13th.
  • if the site timezone is set to UTC-5, UTC-6, UTC-7..., then the block should show November 12th.

#10 follow-up: @Mamaduka
4 weeks ago

Thank you, @kaitohm!

Either place is fine. We'll also need to apply the fix to the legacy RSS widget.

This ticket was mentioned in PR #7798 on WordPress/wordpress-develop by @narenin.


4 weeks ago
#11

  • Keywords has-patch added

#12 in reply to: ↑ 10 @kaitohm
4 weeks ago

Replying to Mamaduka:

Thank you, @kaitohm!

Either place is fine. We'll also need to apply the fix to the legacy RSS widget.

My pleasure! :-)

#13 @narenin
4 weeks ago

@Mamaduka I have added PR fix for the legacy RSS widget.

https://github.com/WordPress/wordpress-develop/pull/7798

#14 @desrosj
3 weeks ago

  • Milestone changed from Awaiting Review to 6.7.2

#15 @pbearne
2 weeks ago

  • Milestone changed from 6.7.2 to 6.8

#16 @pbearne
2 weeks ago

  • Owner set to pbearne
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.