Make WordPress Core

Changeset 34572


Ignore:
Timestamp:
09/26/2015 03:37:53 AM (9 years ago)
Author:
wonderboymusic
Message:

XML-RPC: In wp_xmlrpc_server::mw_newPost(), if $dateCreated is not set, don't set post_date and post_date_gmt. It calls wp_insert_post(), which will handle it correctly. The problem was drafts being created and GMT date being set. It shouldn't be.

Adds unit test.

Fixes #16985.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r34570 r34572  
    49324932            $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
    49334933        } else {
    4934             $post_date = current_time('mysql');
    4935             $post_date_gmt = current_time('mysql', 1);
     4934            $post_date = '';
     4935            $post_date_gmt = '';
    49364936        }
    49374937
  • trunk/tests/phpunit/tests/xmlrpc/mw/newPost.php

    r25002 r34572  
    160160    }
    161161
     162
     163    /**
     164     * @ticket 16985
     165     */
     166    function test_draft_post_date() {
     167        $this->make_user_by_role( 'editor' );
     168
     169        $post = array(
     170            'title' => 'Test',
     171            'post_type' => 'post',
     172            'post_status' => 'draft'
     173        );
     174        $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) );
     175        $this->assertNotInstanceOf( 'IXR_Error', $result );
     176        $this->assertStringMatchesFormat( '%d', $result );
     177
     178        $out = get_post( $result );
     179        $this->assertEquals( 'post', $out->post_type );
     180        $this->assertEquals( 'draft', $out->post_status );
     181        $this->assertEquals( '0000-00-00 00:00:00', $out->post_date_gmt );
     182    }
    162183}
Note: See TracChangeset for help on using the changeset viewer.