WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#18361 closed defect (bug) (invalid)

get_gmt_from_date() returns incorrect time for "0000-00-00 00:00:00"

Reported by: danielbachhuber Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Date/Time Keywords:
Focuses: Cc:

Description

When you pass "0000-00-00 00:00:00" to get_gmt_from_date(), it returns the current time with GMT offset. Instead it should return the original nonsense time (possibly altering format if there's an alternate time format referenced).

Backstory: We have a plugin that allows users to create custom statuses. It uses the partially completed custom status API and additional code we've written. In the WordPress.org forum, a bug was reported where if they use a custom status with a post, the post time is set. Currently, they have to manually edit the timestamp of the post before publishing in order for it to be set to the proper publication date (instead of 5 days ago when they originally created it).

The origin of the problem is line #2506 in wp-includes/post.php. The post statuses to receive timestamps should be whitelisted instead of blacklisted. Because the custom statuses aren't a part of the blacklist, they receive a GMT timesteamp.

Change History (2)

comment:1 @danielbachhuber4 years ago

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

After looking into this further, I realized $post_date is passed to get_gmt_from_date(), not $post_date_gmt with the nonsense date. I'm closing this ticket in favor of #18362

comment:2 @ocean904 years ago

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