WordPress.org

Make WordPress Core

Changeset 33973


Ignore:
Timestamp:
09/09/2015 06:05:47 AM (5 years ago)
Author:
pento
Message:

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

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

Props pento, dd32.

See #33154.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/src/wp-includes/capabilities.php

    r33375 r33973  
    12351235            break;
    12361236        $post = get_post( $comment->comment_post_ID );
    1237         $caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
     1237
     1238        /*
     1239         * If the post doesn't exist, we have an orphaned comment.
     1240         * Fall back to the edit_posts capability, instead.
     1241         */
     1242        if ( $post ) {
     1243            $caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
     1244        } else {
     1245            $caps = map_meta_cap( 'edit_posts', $user_id );
     1246        }
    12381247        break;
    12391248    case 'unfiltered_upload':
Note: See TracChangeset for help on using the changeset viewer.