Make WordPress Core


Ignore:
Timestamp:
06/25/2023 03:18:12 PM (20 months ago)
Author:
joedolson
Message:

Quick/Bulk Edit: Don't set publish date when editing drafts.

Ensure that quick edit does not define a publish date if the post status is one of 'draft', 'pending', or 'auto-draft'.

Props uxtremist, SergeyBiryukov, Denis-de-Bernardy, jane, rfischmann, mista-flo, rutviksavsani, oglekler, joedolson.
Fixes #19907.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/wpAjaxInlineSave.php

    r54722 r56022  
    8888        $this->assertSameSets( array( $t2 ), wp_list_pluck( $post_terms_2, 'term_id' ) );
    8989    }
     90
     91    /**
     92     * When updating a draft in quick edit mode, it should not set the publish date of the post when this one will be published.
     93     *
     94     * @ticket 19907
     95     *
     96     * @covers ::edit_post
     97     */
     98    public function test_quick_edit_draft_should_not_set_publish_date() {
     99        // Become an administrator.
     100        $this->_setRole( 'administrator' );
     101
     102        $user = get_current_user_id();
     103
     104        $post = self::factory()->post->create_and_get(
     105            array(
     106                'post_status' => 'draft',
     107                'post_author' => $user,
     108            )
     109        );
     110
     111        $this->assertSame( 'draft', $post->post_status );
     112
     113        $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     114
     115        // Set up a request.
     116        $_POST['_inline_edit'] = wp_create_nonce( 'inlineeditnonce' );
     117        $_POST['post_ID']      = $post->ID;
     118        $_POST['post_type']    = 'post';
     119        $_POST['content']      = 'content test';
     120        $_POST['excerpt']      = 'excerpt test';
     121        $_POST['_status']      = $post->post_status;
     122        $_POST['post_status']  = $post->post_status;
     123        $_POST['post_author']  = $user;
     124        $_POST['screen']       = 'edit-post';
     125        $_POST['post_view']    = 'list';
     126        $_POST['edit_date']    = 'false';
     127        $_POST['mm']           = '09';
     128        $_POST['jj']           = 11;
     129        $_POST['aa']           = 2020;
     130        $_POST['hh']           = 19;
     131        $_POST['mn']           = 20;
     132        $_POST['ss']           = 11;
     133
     134        // Make the request.
     135        try {
     136            $this->_handleAjax( 'inline-save' );
     137        } catch ( WPAjaxDieContinueException $e ) {
     138            unset( $e );
     139        }
     140
     141        $post = get_post( $post->ID );
     142
     143        $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt );
     144    }
    90145}
Note: See TracChangeset for help on using the changeset viewer.