diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 8e929f38a7..6626937568 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -430,21 +430,23 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid * @since 2.6.0 * @since 5.3.0 The `$post_id` parameter was made optional. * - * @param array $file_array Array that represents a `$_FILES` upload array. - * @param int $post_id Optional. The post ID the media is associated with. - * @param string $desc Optional. Description of the side-loaded file. Default null. - * @param array $post_data Optional. Post data to override. Default empty array. + * @param string[] $file_array Array that represents a `$_FILES` upload array. + * @param int $post_id Optional. The post ID the media is associated with. + * @param string $desc Optional. Description of the side-loaded file. Default null. + * @param array $post_data Optional. Post data to override. Default empty array. * @return int|WP_Error The ID of the attachment or a WP_Error on failure. */ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) { $overrides = array( 'test_form' => false ); - $time = current_time( 'mysql' ); - $post = get_post( $post_id ); - - if ( $post ) { - if ( substr( $post->post_date, 0, 4 ) > 0 ) { + if ( isset( $post_data['post_date'] ) && substr( $post_data['post_date'], 0, 4 ) > 0 ) { + $time = $post_data['post_date']; + } else { + $post = get_post( $post_id ); + if ( $post && substr( $post->post_date, 0, 4 ) > 0 ) { $time = $post->post_date; + } else { + $time = current_time( 'mysql' ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 93a0f0ca6c..c12d072b83 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-beta1-50257'; +$wp_version = '5.7-beta1-50258'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.