mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Capabilities: Fall back to the edit_posts capability for orphaned comments.
Also avoid PHP notices because of orphaned comments in the comments list table. Includes unit test. props pento, dd32. fixes #33154. git-svn-id: https://develop.svn.wordpress.org/trunk@33614 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1305,7 +1305,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 ) ) )
|
||||
|
||||
Reference in New Issue
Block a user