Ticket #19664: recent-comments-fix.diff
File recent-comments-fix.diff, 1.7 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/dashboard.php
619 619 $allowed_states = array('0', '1'); 620 620 else 621 621 $allowed_states = array('1'); 622 622 623 foreach ( $allowed_states as $s ) 624 $allowed_states_sql[] = "comment_approved = '$s'"; 625 626 $allowed_states_sql = 'AND ( ' . implode( ' OR ', $allowed_states_sql ) . ' )'; 627 623 628 // Select all comment types and filter out spam later for better query performance. 624 629 $comments = array(); 625 630 $start = 0; … … 627 632 $widgets = get_option( 'dashboard_widget_options' ); 628 633 $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) 629 634 ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; 635 636 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' $allowed_states_sql ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { 630 637 631 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" ) ) {632 633 638 foreach ( $possible as $comment ) { 634 639 if ( count( $comments ) >= $total_items ) 635 640 break; 636 if ( in_array( $comment->comment_approved, $allowed_states ) &¤t_user_can( 'read_post', $comment->comment_post_ID ) )641 if ( current_user_can( 'read_post', $comment->comment_post_ID ) ) 637 642 $comments[] = $comment; 638 643 } 639 644