WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/14/2014 08:10:14 AM (7 years ago)
Author:
nacin
Message:

Avoid stomping of bulk postdata inside the bulk_edit_posts() loop.

Merge [28113] to the 3.8 branch.

Reverts [27991] which did not fix it for authors and comment/ping status.

props dd32, DrewAPicture.
fixes #27792.

Location:
branches/3.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8

  • branches/3.8/tests/phpunit/tests/admin/includesPost.php

    r28073 r28114  
    135135        $this->assertEquals( 'draft', $updated->post_status );
    136136    }
     137
     138    /**
     139     * @ticket 27792
     140     */
     141    function test_bulk_edit_posts_stomping() {
     142        $admin = $this->factory->user->create( array( 'role' => 'administrator' ) );
     143        $users = $this->factory->user->create_many( 2, array( 'role' => 'author' ) );
     144        wp_set_current_user( $admin );
     145
     146        $post1 = $this->factory->post->create( array(
     147            'post_author'    => $users[0],
     148            'comment_status' => 'open',
     149            'ping_status'    => 'open',
     150            'post_status'    => 'publish',
     151        ) );
     152
     153        $post2 = $this->factory->post->create( array(
     154            'post_author'    => $users[1],
     155            'comment_status' => 'closed',
     156            'ping_status'    => 'closed',
     157            'post_status'    => 'draft',
     158        ) );
     159
     160        $request = array(
     161            'post_type'        => 'post',
     162            'post_author'      => -1,
     163            'ping_status'      => -1,
     164            'comment_status'   => -1,
     165            '_status'          => -1,
     166            'post'             => array( $post1, $post2 ),
     167        );
     168
     169        $done = bulk_edit_posts( $request );
     170
     171        $post = get_post( $post2 );
     172
     173        // Check that the first post's values don't stomp the second post.
     174        $this->assertEquals( 'draft', $post->post_status );
     175        $this->assertEquals( $users[1], $post->post_author );
     176        $this->assertEquals( 'closed', $post->comment_status );
     177        $this->assertEquals( 'closed', $post->ping_status );
     178    }
     179
    137180}
Note: See TracChangeset for help on using the changeset viewer.