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

Built from https://develop.svn.wordpress.org/trunk@31983


git-svn-id: http://core.svn.wordpress.org/trunk@31962 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-04-02 15:49:30 +00:00
parent 3ac2f91922
commit c996169c04
2 changed files with 20 additions and 14 deletions

View File

@ -4756,20 +4756,26 @@ class wp_xmlrpc_server extends IXR_Server {
$post_author = $postdata['post_author'];
// Only set the post_author if one is set.
if ( isset($content_struct['wp_author_id']) && ($user->ID != $content_struct['wp_author_id']) ) {
switch ( $post_type ) {
case 'post':
if ( !current_user_can('edit_others_posts') )
return new IXR_Error( 401, __( 'You are not allowed to change the post author as this user.' ) );
break;
case 'page':
if ( !current_user_can('edit_others_pages') )
return new IXR_Error( 401, __( 'You are not allowed to change the page author as this user.' ) );
break;
default:
return new IXR_Error( 401, __( 'Invalid post type' ) );
if ( isset( $content_struct['wp_author_id'] ) ) {
// Check permissions if attempting to switch author to or from another user.
if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) {
switch ( $post_type ) {
case 'post':
if ( ! current_user_can( 'edit_others_posts' ) ) {
return new IXR_Error( 401, __( 'You are not allowed to change the post author as this user.' ) );
}
break;
case 'page':
if ( ! current_user_can( 'edit_others_pages' ) ) {
return new IXR_Error( 401, __( 'You are not allowed to change the page author as this user.' ) );
}
break;
default:
return new IXR_Error( 401, __( 'Invalid post type' ) );
break;
}
$post_author = $content_struct['wp_author_id'];
}
$post_author = $content_struct['wp_author_id'];
}
if ( isset($content_struct['mt_allow_comments']) ) {

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta3-31982';
$wp_version = '4.2-beta3-31983';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.