WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7180 closed defect (bug) (duplicate)

Feed item date is Nov 29, 1999 (bad post_date_gmt)

Reported by: dougal Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5.1
Component: General Keywords: rss, atom, feeds, timestamp, posts, post_date_gmt, 1999, nov 29
Focuses: Cc:

Description

I've observed this in both 2.5 branch (post 2.5.1 release), and in 2.6b1. I haven't come up with a way to reliably reproduce it. I suspect, however, that it might have something to do with autosave?

On recently published items, the post_date_gmt field is sometimes not getting set (value '0000-00-00 00:00:00'). Oddly enough, with post revisions, post_date_gmt *is* set correctly, but not on the final published version. The most visible side-effect is that items in feeds have the wrong timestamp. Of the last six posts on my site, three exhibit this problem, but I can't find a pattern to which ones do and don't.

Change History (5)

comment:1 DD326 years ago

See Also #6483

comment:2 ryan6 years ago

Possibly related: #6527

comment:3 dougal6 years ago

  • Cc dougal added

Ticket #6483 might not *directly* apply, because I'm just using the web interface to post, not the API. However, it's possible (likely?) that the same underlying bug is at work here.

I still haven't been able to reliably replicate the problem, though I haven't had a whole lot of time to test it, either. I do wonder if it could be a plugin side-effect. In particular, I have the 'Automatic Timezone' plugin installed. I don't think any of my other plugins would have any major interaction with timestamps or post saving.

Just as an FYI for other people who find this ticket, if you want to fix the timestamps, try using a SQL query like so:

`UPDATE wp_posts

SET post_date_gmt = ADDTIME(post_date, '04:00:00')
WHERE post_date_gmt = '0000-00-00 00:00:00'

AND post_date <> '0000-00-00 00:00:00'
AND post_status = 'publish';`

In this case, we're assuming that you are in the EDT (GMT -04:00) timezone, so we're adding 4 hours back to the post_date to calculate post_date_gmt. Adust the '04:00:00' value accordingly for your timezone. If you are east of the international date line (positive GMT offset), then use the SUBTIME() function instead of ADDTIME().

Also, it doesn't take Daylight Savings into acccount, so if you have posts that were affected before and after a time change, you might want to add appropriate WHERE clauses and run two queries with the different adjustments.

comment:4 dougal6 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Closing this as a dup of #6527 since that one has patches that have gone into trunk. Please also backport to 2.6.1 while it is still beta.

comment:5 santosj6 years ago

  • Milestone 2.9 deleted
Note: See TracTickets for help on using tickets.