WordPress.org

Make WordPress Core

Changeset 27405


Ignore:
Timestamp:
03/05/2014 06:25:31 AM (7 years ago)
Author:
nacin
Message:

Always convert auto-drafts to drafts in edit_draft() and _wp_translate_postdata().

This regressed due to refactoring in [26995]. This commit fixes Quick Draft.

see #25272.

Location:
trunk
Files:
2 edited

Legend:

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

    r27373 r27405  
    8484
    8585        // No longer an auto-draft
    86         if ( 'auto-draft' == $post_data['post_status'] )
     86        if ( 'auto-draft' === $post_data['post_status'] ) {
    8787            $post_data['post_status'] = 'draft';
     88        }
    8889    }
    8990
     
    114115            $post_data['post_status'] = 'pending';
    115116
    116     if ( ! isset($post_data['post_status']) )
    117         $post_data['post_status'] = $previous_status;
     117    if ( ! isset( $post_data['post_status'] ) ) {
     118        $post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status;
     119    }
    118120
    119121    if (!isset( $post_data['comment_status'] ))
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r25002 r27405  
    115115        wp_set_current_user( 0 );
    116116    }
     117
     118    /**
     119     * edit_post() should convert an existing auto-draft to a draft.
     120     *
     121     * @ticket 25272
     122     */
     123    function test_edit_post_auto_draft() {
     124        $user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
     125        wp_set_current_user( $user_id );
     126        $post = $this->factory->post->create_and_get( array( 'post_status' => 'auto-draft' ) );
     127        $this->assertEquals( 'auto-draft', $post->post_status );
     128        $post_data = array(
     129            'post_title' => 'Post title',
     130            'content' => 'Post content',
     131            'post_type' => 'post',
     132            'post_ID' => $post->ID,
     133        );
     134        edit_post( $post_data );
     135        $this->assertEquals( 'draft', get_post( $post->ID )->post_status );
     136        wp_set_current_user( 0 );
     137    }
     138
    117139}
Note: See TracChangeset for help on using the changeset viewer.