Ticket #14222: 14222.4.patch
| File 14222.4.patch, 1.6 KB (added by SergeyBiryukov, 21 months ago) |
|---|
-
wp-admin/includes/dashboard.php
612 612 global $wpdb; 613 613 614 614 if ( current_user_can('edit_posts') ) 615 $allowed_states = array('0', '1');615 $allowed_states = "c.comment_approved IN ('0','1') AND"; 616 616 else 617 $allowed_states = array('1');617 $allowed_states = "c.comment_approved = '1' AND"; 618 618 619 // Select all comment types and filter out spam later for better query performance.620 619 $comments = array(); 621 620 $start = 0; 622 621 … … 624 623 $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) 625 624 ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; 626 625 627 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 WHEREp.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {626 while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT c.* FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE $allowed_states p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { 628 627 629 628 foreach ( $possible as $comment ) { 630 629 if ( count( $comments ) >= $total_items ) 631 630 break; 632 if ( in_array( $comment->comment_approved, $allowed_states ) &¤t_user_can( 'read_post', $comment->comment_post_ID ) )631 if ( current_user_can( 'read_post', $comment->comment_post_ID ) ) 633 632 $comments[] = $comment; 634 633 } 635 634