WordPress.org

Make WordPress Core

Ticket #16846: 16846-2.patch

File 16846-2.patch, 1.6 KB (added by azaozz, 7 years ago)

Includes the patch by ocean90, bypasses the "can read" check for users that can moderate comments

  • dashboard.php

     
    604604        // Select all comment types and filter out spam later for better query performance.
    605605        $comments = array();
    606606        $start = 0;
     607        $can_moderate = current_user_can( 'moderate_comments' );
    607608
    608609        $widgets = get_option( 'dashboard_widget_options' );
    609610        $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )
    610611                ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;
    611612
    612         while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
     613        if ( $total_items < 1 || $total_items > 50 ) // some sanity
     614                $total_items = 5;
    613615
     616        while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
     617
    614618                foreach ( $possible as $comment ) {
    615619                        if ( count( $comments ) >= $total_items )
    616620                                break;
    617                         if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) )
     621                        if ( in_array( $comment->comment_approved, $allowed_states ) && ( $can_moderate || current_user_can( 'read_post', $comment->comment_post_ID ) ) )
    618622                                $comments[] = $comment;
    619623                }
    620624