From df480edb249ab2db7748c5391319f761cd853f1d Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 13 Aug 2015 15:27:57 +0000 Subject: [PATCH] After [33325], supply a missing `post_type` in `->mw_editPost()`. Add unit test. Props ocean90. Fixes #20662. git-svn-id: https://develop.svn.wordpress.org/trunk@33612 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-xmlrpc-server.php | 1 + tests/phpunit/tests/xmlrpc/mw/editPost.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index dab9863887..8e7bfb6ce2 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -5281,6 +5281,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { $data = $newpost; $data['sticky'] = $content_struct['sticky']; + $data['post_type'] = 'post'; $error = $this->_toggle_sticky( $data, true ); if ( $error ) { return $error; diff --git a/tests/phpunit/tests/xmlrpc/mw/editPost.php b/tests/phpunit/tests/xmlrpc/mw/editPost.php index 7d7ef3fbef..50f97929e3 100644 --- a/tests/phpunit/tests/xmlrpc/mw/editPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/editPost.php @@ -113,7 +113,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $out = get_post( $post_id ); $this->assertEquals( $editor_id, $out->post_author ); } - + function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); @@ -203,6 +203,20 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertEquals( $post4['mt_excerpt'], $out->post_excerpt ); } + /** + * @ticket 20662 + */ + function test_make_post_sticky() { + $author_id = $this->make_user_by_role( 'editor' ); + + $post = array( 'post_title' => 'Title', 'post_content' => 'Content', 'post_author' => $author_id, 'post_status' => 'publish' ); + $post_id = wp_insert_post( $post ); + + $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', array( 'sticky' => '1' ) ) ); + $this->assertNotInstanceOf( 'IXR_Error', $result ); + $this->assertTrue( $result ); + } + // Not allowed since [19914] function test_change_post_type() { $contributor_id = $this->make_user_by_role( 'contributor' );