Ticket #16846: 16846-2.patch
| File 16846-2.patch, 1.6 KB (added by azaozz, 2 years ago) |
|---|
-
dashboard.php
604 604 // Select all comment types and filter out spam later for better query performance. 605 605 $comments = array(); 606 606 $start = 0; 607 $can_moderate = current_user_can( 'moderate_comments' ); 607 608 608 609 $widgets = get_option( 'dashboard_widget_options' ); 609 610 $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) 610 611 ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; 611 612 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; 613 615 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 614 618 foreach ( $possible as $comment ) { 615 619 if ( count( $comments ) >= $total_items ) 616 620 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 ) ) ) 618 622 $comments[] = $comment; 619 623 } 620 624
