Capabilities: Fall back to the `edit_posts` capability for orphaned comments.

Merge of the `capabilities.php` part of [33614] to the 3.7 branch.

Props pento, dd32.

Fixes #33154.


Built from https://develop.svn.wordpress.org/branches/3.7@33977


git-svn-id: http://core.svn.wordpress.org/branches/3.7@33946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2015-09-09 06:29:09 +00:00
parent 1f59bf6469
commit 1b2e6cfa1d
1 changed files with 10 additions and 1 deletions

View File

@ -1184,7 +1184,16 @@ function map_meta_cap( $cap, $user_id ) {
if ( empty( $comment ) )
break;
$post = get_post( $comment->comment_post_ID );
$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
/*
* If the post doesn't exist, we have an orphaned comment.
* Fall back to the edit_posts capability, instead.
*/
if ( $post ) {
$caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
} else {
$caps = map_meta_cap( 'edit_posts', $user_id );
}
break;
case 'unfiltered_upload':
if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) ) )