Date/Time: In `wp_insert_post()`, when checking the post date to set `future` or `publish` status, use string comparison to work around far future dates (year 2038+) on 32-bit systems.

Props Rarst, nofearinc.
Fixes #25347.
Built from https://develop.svn.wordpress.org/trunk@45851


git-svn-id: http://core.svn.wordpress.org/trunk@45662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-08-19 15:50:56 +00:00
parent 3541c5d74c
commit a58eaa9424
2 changed files with 6 additions and 7 deletions

View File

@ -3663,14 +3663,13 @@ function wp_insert_post( $postarr, $wp_error = false ) {
} }
if ( 'attachment' !== $post_type ) { if ( 'attachment' !== $post_type ) {
if ( 'publish' == $post_status ) { if ( 'publish' === $post_status ) {
$now = gmdate( 'Y-m-d H:i:59' ); // String comparison to work around far future dates (year 2038+) on 32-bit systems.
if ( mysql2date( 'U', $post_date_gmt, false ) > mysql2date( 'U', $now, false ) ) { if ( $post_date_gmt > gmdate( 'Y-m-d H:i:59' ) ) {
$post_status = 'future'; $post_status = 'future';
} }
} elseif ( 'future' == $post_status ) { } elseif ( 'future' === $post_status ) {
$now = gmdate( 'Y-m-d H:i:59' ); if ( $post_date_gmt <= gmdate( 'Y-m-d H:i:59' ) ) {
if ( mysql2date( 'U', $post_date_gmt, false ) <= mysql2date( 'U', $now, false ) ) {
$post_status = 'publish'; $post_status = 'publish';
} }
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3-alpha-45850'; $wp_version = '5.3-alpha-45851';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.