From a58eaa9424ea4a3e15a0a6d3ab54616e46397381 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 19 Aug 2019 15:50:56 +0000 Subject: [PATCH] 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 --- wp-includes/post.php | 11 +++++------ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 7636c3d02b..306e567bb9 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3663,14 +3663,13 @@ function wp_insert_post( $postarr, $wp_error = false ) { } if ( 'attachment' !== $post_type ) { - if ( 'publish' == $post_status ) { - $now = gmdate( 'Y-m-d H:i:59' ); - if ( mysql2date( 'U', $post_date_gmt, false ) > mysql2date( 'U', $now, false ) ) { + if ( 'publish' === $post_status ) { + // String comparison to work around far future dates (year 2038+) on 32-bit systems. + if ( $post_date_gmt > gmdate( 'Y-m-d H:i:59' ) ) { $post_status = 'future'; } - } elseif ( 'future' == $post_status ) { - $now = gmdate( 'Y-m-d H:i:59' ); - if ( mysql2date( 'U', $post_date_gmt, false ) <= mysql2date( 'U', $now, false ) ) { + } elseif ( 'future' === $post_status ) { + if ( $post_date_gmt <= gmdate( 'Y-m-d H:i:59' ) ) { $post_status = 'publish'; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index e4c76f0ea0..5a3e022021 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @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.