From d31387d674d85e41d1ca19ef116f5f4738fc295b Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 5 Dec 2008 23:42:06 +0000 Subject: [PATCH] Speed up Recent Comments dash module query git-svn-id: https://develop.svn.wordpress.org/trunk@10079 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/dashboard.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 80dfc5457e..716b38a8a2 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -396,17 +396,25 @@ function wp_dashboard_recent_drafts( $drafts = false ) { * @since unknown */ function wp_dashboard_recent_comments() { - $status = ( current_user_can('edit_posts') ) ? '' : 'approved'; + global $wpdb; - list($comments, $total) = _wp_get_comment_list( $status, false, 0, 5 ); + if ( current_user_can('edit_posts') ) + $allowed_states = array('0', '1'); + else + $allowed_states = array('1'); + + // Select all comment types and filter out spam later for better query performance. + $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT 0, 50" ); if ( $comments ) : ?>
comment_approved, $allowed_states) ) + _wp_dashboard_recent_comments_row( $comment ); + } ?>