Make WordPress Core


Ignore:
Timestamp:
08/13/2015 10:30:26 PM (11 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

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

    r33357 r33614  
    13061306                        break;
    13071307                $post = get_post( $comment->comment_post_ID );
    1308                 $caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
     1308
     1309                /*
     1310                 * If the post doesn't exist, we have an orphaned comment.
     1311                 * Fall back to the edit_posts capability, instead.
     1312                 */
     1313                if ( $post ) {
     1314                        $caps = map_meta_cap( 'edit_post', $user_id, $post->ID );
     1315                } else {
     1316                        $caps = map_meta_cap( 'edit_posts', $user_id );
     1317                }
    13091318                break;
    13101319        case 'unfiltered_upload':
Note: See TracChangeset for help on using the changeset viewer.