X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6359b807ff8b4ffa151d8756cdefb861c6c1d4db..f5fcdc7994bb67cce809bc4777944ae8b7fad4a4:/wp-includes/capabilities.php diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 8a3d3350..b73eb41b 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -1260,7 +1260,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 ) ) )