[wp-trac] [WordPress Trac] #48623: WP 5.3 time problem causes day number shifts in permalinks

WordPress Trac noreply at wordpress.org
Mon Nov 18 10:28:19 UTC 2019


#48623: WP 5.3 time problem causes day number shifts in permalinks
--------------------------------------+---------------------
 Reporter:  steevithak                |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  5.3.1
Component:  Date/Time                 |     Version:  5.3
 Severity:  critical                  |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------
Changes (by Cybr):

 * severity:  major => critical


Comment:

 I think the recent change also causes canonical URL issues `<link
 rel=canonical href=... />`. Whether that's outputted via WordPress itself,
 or via an SEO plugin that doesn't rectify this, this canonical URL causes
 404 responses and can **take down sites from search engines**. Therefore,
 I'm marking this ticket as critical.

 Now, this isn't necessarily a plugin conflict problem, because even when
 `date_default_timezone_get()` isn't used, PHP still has this configuration
 setting:
 [https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
 date.timezone].

 When either is set to anything but UTC, `gmdate()` will return offsetted
 dates. But, the timestamp used in `get_permalink()` (`$post->post_date`)
 is always UTC (instigated in `touch_time()` via `current_time()`).

 Before 5.3, in `get_permalink()`, WordPress used `date()` instead of
 `gmdate()`, which worked perfectly.
 ([https://core.trac.wordpress.org/browser/tags/5.2/src/wp-includes/link-
 template.php#L215 source])

 Reverting that change should fix the issue. I haven't found the time to
 create a proof of concept. So, please do test this if you can.

 Alternatively, you could add the known PHP offset to the `$unixtime`
 variable, and then keep using the `gmdate()` function as shown below.
 However, I think this is redundant and unfavorable to the revert.
 {{{
 $unixtime = strtotime( $post->post_date ) + date( 'Z' );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48623#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list