Make WordPress Core

Ticket #19907: 19907.3.patch

File 19907.3.patch, 2.4 KB (added by Mista-Flo, 4 years ago)
  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index c0e5e1fc70..a2ff106a5a 100644
    a b function wp_insert_post( $postarr, $wp_error = false ) { 
    38023802                } else {
    38033803                        $post_date_gmt = '0000-00-00 00:00:00';
    38043804                }
     3805        } elseif ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
     3806                $post_date_gmt = '0000-00-00 00:00:00';
    38053807        } else {
    38063808                $post_date_gmt = $postarr['post_date_gmt'];
    38073809        }
  • tests/phpunit/tests/ajax/QuickEdit.php

    diff --git a/tests/phpunit/tests/ajax/QuickEdit.php b/tests/phpunit/tests/ajax/QuickEdit.php
    index 2369930cfb..6542ee5808 100644
    a b class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase { 
    8383                $post_terms_2 = wp_get_object_terms( $post->ID, 'wptests_tax_2' );
    8484                $this->assertSameSets( array( $t2 ), wp_list_pluck( $post_terms_2, 'term_id' ) );
    8585        }
     86
     87        /**
     88         * When updating a draft in quick edit mode, it should not set the publish date of the post when this one will be published.
     89         *
     90         * @ticket 19907
     91         */
     92        public function test_quick_edit_draft_should_not_set_publish_date() {
     93                // Become an administrator.
     94                $this->_setRole( 'administrator' );
     95
     96                $user = get_current_user_id();
     97
     98                $post = self::factory()->post->create_and_get(
     99                        array(
     100                                'post_status' => 'draft',
     101                                'post_author' => $user,
     102                        )
     103                );
     104
     105                $this->assertSame( 'draft', $post->post_status );
     106
     107                $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     108
     109                // Set up a request.
     110                $_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' );
     111                $_POST['post_ID']      = $post->ID;
     112                $_POST['post_type']    = 'post';
     113                $_POST['content']      = 'content test';
     114                $_POST['excerpt']      = 'excerpt test';
     115                $_POST['_status']      = $post->post_status;
     116                $_POST['post_status']  = $post->post_status;
     117                $_POST['post_author']  = $user;
     118                $_POST['screen']       = 'edit-post';
     119                $_POST['post_view']    = 'list';
     120                $_POST['edit_date']    = true;
     121                $_POST['mm']           = '09';
     122                $_POST['jj']           = 11;
     123                $_POST['aa']           = 2020;
     124                $_POST['hh']           = 19;
     125                $_POST['mn']           = 20;
     126                $_POST['ss']           = 11;
     127
     128                // Make the request.
     129                try {
     130                        $this->_handleAjax( 'inline-save' );
     131                } catch ( WPAjaxDieContinueException $e ) {
     132                        unset( $e );
     133                }
     134
     135                $post = get_post( $post->ID );
     136
     137                $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     138        }
    86139}