WordPress.org

Make WordPress Core

Ticket #48113: 48113.diff

File 48113.diff, 1.6 KB (added by TimothyBlynJacobs, 2 years ago)
  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index dde54c510d..fb5a86318e 100644
    a b function wp_insert_post( $postarr, $wp_error = false ) { 
    37263726        }
    37273727
    37283728        if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) {
    3729                 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
     3729                if ( ! in_array( $post_status, get_post_stati( array( 'date_floating' => true ) ), true ) ) {
    37303730                        $post_date_gmt = get_gmt_from_date( $post_date );
    37313731                } else {
    37323732                        $post_date_gmt = '0000-00-00 00:00:00';
  • tests/phpunit/tests/post.php

    diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php
    index 6ef0c8449f..dec4f9ece9 100644
    a b class Tests_Post extends WP_UnitTestCase { 
    13911391                remove_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 );
    13921392        }
    13931393
     1394        /**
     1395         * @ticket 48113
     1396         */
     1397        public function test_insert_post_should_respect_date_floating_post_status_arg() {
     1398                register_post_status( 'floating', array( 'date_floating' => true ) );
     1399
     1400                $post_id = self::factory()->post->create(
     1401                        array(
     1402                                'post_status'   => 'floating',
     1403                                'post_date'     => null,
     1404                                'post_date_gmt' => null,
     1405                        )
     1406                );
     1407
     1408                $post = get_post( $post_id );
     1409                self::assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     1410        }
     1411
    13941412        function filter_pre_wp_unique_post_slug( $default, $slug, $post_ID, $post_status, $post_type, $post_parent ) {
    13951413                return 'override-slug-' . $post_type;
    13961414        }