WordPress.org

Make WordPress Core

Changeset 28073


Ignore:
Timestamp:
04/11/2014 04:33:06 AM (4 years ago)
Author:
nacin
Message:

Ensure edit_post() promotes an auto-draft to draft. Fixes Quick Draft.

For the 3.8 branch. Regression from [27976] that does not affect trunk.

props dd32.
see #27734.

Location:
branches/3.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8/src/wp-admin/includes/post.php

    r27991 r28073  
    204204    }
    205205
    206     if ( ( empty( $post_data['action'] ) || 'autosave' != $post_data['action'] ) && 'auto-draft' == $post_data['post_status'] ) {
    207         $post_data['post_status'] = 'draft';
    208     }
    209 
    210206    if ( isset($post_data['visibility']) ) {
    211207        switch ( $post_data['visibility'] ) {
     
    227223    if ( is_wp_error($post_data) )
    228224        wp_die( $post_data->get_error_message() );
     225
     226    if ( ( empty( $post_data['action'] ) || 'autosave' != $post_data['action'] ) && 'auto-draft' == $post_data['post_status'] ) {
     227        $post_data['post_status'] = 'draft';
     228    }
    229229
    230230    // Post Formats
  • branches/3.8/tests/phpunit/tests/admin/includesPost.php

    r25002 r28073  
    55 */
    66class Tests_Admin_includesPost extends WP_UnitTestCase {
     7
     8    function tearDown() {
     9        wp_set_current_user( 0 );
     10        parent::tearDown();
     11    }
    712
    813    function test__wp_translate_postdata_cap_checks_contributor() {
     
    5762        $this->assertEquals( 'edit_others_posts', $_results->get_error_code() );
    5863        $this->assertEquals( 'You are not allowed to edit posts as this user.', $_results->get_error_message() );
    59 
    60         wp_set_current_user( 0 );
    6164    }
    6265
     
    112115        $this->assertEquals( $_post_data['post_author'], $_results['post_author'] );
    113116        $this->assertEquals( 'draft', $_results['post_status'] );
     117    }
    114118
    115         wp_set_current_user( 0 );
     119    /**
     120     * @ticket 27734
     121     */
     122    function test_edit_post_promotes_auto_draft_to_draft() {
     123        $admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
     124        wp_set_current_user( $admin );
     125
     126        $post = get_default_post_to_edit( 'post', true );
     127        $post_data = array(
     128            'post_ID' => $post->ID,
     129            'post_type' => 'post',
     130            'post_content' => 'Some content',
     131        );
     132        $this->assertEquals( 'auto-draft', $post->post_status );
     133        edit_post( $post_data );
     134        $updated = get_post( $post->ID );
     135        $this->assertEquals( 'draft', $updated->post_status );
    116136    }
    117137}
Note: See TracChangeset for help on using the changeset viewer.