diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 99674382ef..c617bfa021 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -116,22 +116,22 @@ class WP_Comments_List_Table extends WP_List_Table { ); $_comments = get_comments( $args ); + if ( is_array( $_comments ) ) { + update_comment_cache( $_comments ); - update_comment_cache( $_comments ); + $this->items = array_slice( $_comments, 0, $comments_per_page ); + $this->extra_items = array_slice( $_comments, $comments_per_page ); - $this->items = array_slice( $_comments, 0, $comments_per_page ); - $this->extra_items = array_slice( $_comments, $comments_per_page ); + $_comment_post_ids = array_unique( wp_list_pluck( $_comments, 'comment_post_ID' ) ); - $total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); - - $_comment_post_ids = array(); - foreach ( $_comments as $_c ) { - $_comment_post_ids[] = $_c->comment_post_ID; + $this->pending_count = get_pending_comments_num( $_comment_post_ids ); } - $_comment_post_ids = array_unique( $_comment_post_ids ); - - $this->pending_count = get_pending_comments_num( $_comment_post_ids ); + $total_comments = get_comments( array_merge( $args, array( + 'count' => true, + 'offset' => 0, + 'number' => 0 + ) ) ); $this->set_pagination_args( array( 'total_items' => $total_comments, diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 7179aa3480..6078353450 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -766,6 +766,9 @@ 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 ) ) { + break; + } foreach ( $possible as $comment ) { if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) continue; diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index eb4950d985..3fa3eb0a34 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -3196,12 +3196,13 @@ class wp_xmlrpc_server extends IXR_Server { if ( isset($struct['number']) ) $number = absint($struct['number']); - $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) ); + $comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) ); $comments_struct = array(); - - foreach ( $comments as $comment ) { - $comments_struct[] = $this->_prepare_comment( $comment ); + if ( is_array( $comments ) ) { + foreach ( $comments as $comment ) { + $comments_struct[] = $this->_prepare_comment( $comment ); + } } return $comments_struct; diff --git a/src/wp-includes/default-widgets.php b/src/wp-includes/default-widgets.php index 2416b5bbc7..55a7782d0f 100644 --- a/src/wp-includes/default-widgets.php +++ b/src/wp-includes/default-widgets.php @@ -1009,7 +1009,7 @@ class WP_Widget_Recent_Comments extends WP_Widget { } $output .= '