mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Correctly set the post author in wp_xmlrpc_server::mw_editPost() when the current user is not the author of the post.
Props redsweater, markoheijnen, DrewAPicture Fixes #24916 git-svn-id: https://develop.svn.wordpress.org/trunk@31983 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -95,6 +95,25 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertEquals( $contributor_id, $out->post_author );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 24916
|
||||
*/
|
||||
function test_capable_reassign_author_to_self() {
|
||||
$contributor_id = $this->make_user_by_role( 'contributor' );
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
|
||||
$post_id = wp_insert_post( $post );
|
||||
|
||||
$post2 = array( 'wp_author_id' => $editor_id );
|
||||
$result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'editor', 'editor', $post2 ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
$this->assertTrue($result);
|
||||
|
||||
$out = get_post( $post_id );
|
||||
$this->assertEquals( $editor_id, $out->post_author );
|
||||
}
|
||||
|
||||
function test_post_thumbnail() {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
|
||||
|
||||
@@ -95,6 +95,25 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertEquals( $contributor_id, $out->post_author );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 24916
|
||||
*/
|
||||
function test_capable_reassign_author_to_self() {
|
||||
$contributor_id = $this->make_user_by_role( 'contributor' );
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post = array( 'post_title' => 'Post test', 'post_author' => $contributor_id );
|
||||
$post_id = wp_insert_post( $post );
|
||||
|
||||
$post2 = array( 'post_author' => $editor_id );
|
||||
$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $post2 ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
$this->assertTrue($result);
|
||||
|
||||
$out = get_post( $post_id );
|
||||
$this->assertEquals( $editor_id, $out->post_author );
|
||||
}
|
||||
|
||||
function test_post_thumbnail() {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user