]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/capabilities.php
WordPress 4.2.5-scripts
[autoinstalls/wordpress.git] / wp-includes / capabilities.php
index 588432dcfc717d272bf5ca4e3e687380b76700ee..b73eb41b3c31f7edb3143104a72f2137d2bc1949 100644 (file)
@@ -1143,8 +1143,10 @@ function map_meta_cap( $cap, $user_id ) {
        case 'edit_post':
        case 'edit_page':
                $post = get_post( $args[0] );
-               if ( empty( $post ) )
+               if ( empty( $post ) ) {
+                       $caps[] = 'do_not_allow';
                        break;
+               }
 
                if ( 'revision' == $post->post_type ) {
                        $post = get_post( $post->post_parent );
@@ -1258,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 ) )  )