Posts: In wp_insert_post(), don't set post_date to current time if it can be derived from a passed value for post_date_gmt.

Adds unit tests.

Props oso96_2000, kawauso.
Fixes #15946.

Built from https://develop.svn.wordpress.org/trunk@34762


git-svn-id: http://core.svn.wordpress.org/trunk@34727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-10-02 04:36:24 +00:00
parent 7a0f8602f3
commit 5c6c4e3713
2 changed files with 6 additions and 2 deletions

View File

@ -3012,7 +3012,11 @@ function wp_insert_post( $postarr, $wp_error = false ) {
* is not 'draft' or 'pending', set date to now.
*/
if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) {
$post_date = current_time( 'mysql' );
if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
$post_date = current_time( 'mysql' );
} else {
$post_date = get_date_from_gmt( $postarr['post_date_gmt'] );
}
} else {
$post_date = $postarr['post_date'];
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34761';
$wp_version = '4.4-alpha-34762';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.