Make WordPress Core

Opened 5 years ago

#47307 new defect (bug)

wp_insert_post: status 'future' is saved although 'publish' selected

Reported by: daniol's profile daniol Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2
Component: Posts, Post Types Keywords: has-patch
Focuses: administration Cc:

Description

If I change the title of the page using the customizer, the changes are not saved because the changeset post is saved with status 'future' although 'publish' selected.

I debugged the issue and found the following fragment of code of wp_insert_post is causing the issue:

<?php
if ( mysql2date( 'U', $post_date_gmt, false ) > mysql2date( 'U', $now, false ) ) {
 $post_status = 'future';
}

This piece of code has no sense, because when the status is set as "publish", we don't want to change artificially to "future" because the publish date is now.

It seems an issue with some versions of PHP/MYSQL, since is working on my local host (Windows) but not on the production server (PHP7.0, Ubuntu).

I debugged the components of the comparison:

$now => 2019-05-17 16:32:59
$post_date_gmt => 2019-05-17 18:32:59
mysql2date( 'U', $post_date_gmt, false ) => 1558110779
mysql2date( 'U', $now, false ) => 1558103579

The date/time configuration of the server is:

root@srvde1 ~ # date
Fri May 17 18:33:24 CEST 2019

There are other affected users over the years, searching on the Internet "customizer does not save changes".

Attachments (1)

status_published_date_fix.patch (774 bytes) - added by daniol 5 years ago.
Fix patch (V. 5.2)

Download all attachments as: .zip

Change History (1)

@daniol
5 years ago

Fix patch (V. 5.2)

Note: See TracTickets for help on using tickets.