Make WordPress Core


Ignore:
Timestamp:
08/29/2019 02:09:42 AM (5 years ago)
Author:
SergeyBiryukov
Message:

XML-RPC: Make sure editing a draft post with wp.editPost does not unintentionally cause its published date to be set.

Props redsweater.
Fixes #45322.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php

    r45607 r45906  
    497497        $this->assertEquals( $future_date_string, $after->post_date );
    498498    }
     499
     500    /**
     501     * @ticket 45322
     502     */
     503    function test_draft_not_assigned_published_date() {
     504        $editor_id = $this->make_user_by_role( 'editor' );
     505
     506        // Start with a draft post, confirming its post_date_gmt is "zero".
     507        $post    = array(
     508            'post_title'  => 'Test',
     509            'post_status' => 'draft',
     510        );
     511        $post_id = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) );
     512
     513        $before  = get_post( $post_id );
     514        $this->assertEquals( '0000-00-00 00:00:00', $before->post_date_gmt );
     515
     516        // Edit the post without specifying any dates.
     517        $new_post_content = array(
     518            'ID'         => $post_id,
     519            'post_title' => 'Updated',
     520        );
     521
     522        $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) );
     523
     524        // The published date should still be zero.
     525        $after = get_post( $post_id );
     526        $this->assertEquals( '0000-00-00 00:00:00', $after->post_date_gmt );
     527    }
    499528}
Note: See TracChangeset for help on using the changeset viewer.