diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index b198325f27..2d79d81622 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -1074,8 +1074,10 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { $comments_query['status'] = 'approve'; } - while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { - if ( ! is_array( $possible ) ) { + do { + $possible = get_comments( $comments_query ); + + if ( empty( $possible ) || ! is_array( $possible ) ) { break; } @@ -1088,16 +1090,17 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { continue; } - $comments[] = $comment; + $comments[] = $comment; + $comments_count = count( $comments ); - if ( count( $comments ) === $total_items ) { + if ( $comments_count === $total_items ) { break 2; } } $comments_query['offset'] += $comments_query['number']; $comments_query['number'] = $total_items * 10; - } + } while ( $comments_count < $total_items ); if ( $comments ) { echo '