From c1d7e7f5aacc7899613eda3691807a2a36a759a2 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 28 Sep 2015 15:09:46 +0000 Subject: [PATCH] In `get_page_of_comment()`, use a true `COUNT` query. This improves memory usage by not compiling a list of comment IDs. See #34057. git-svn-id: https://develop.svn.wordpress.org/trunk@34661 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/comment-functions.php b/src/wp-includes/comment-functions.php index 67bd33e677..1380422d4a 100644 --- a/src/wp-includes/comment-functions.php +++ b/src/wp-includes/comment-functions.php @@ -879,6 +879,7 @@ function get_page_of_comment( $comment_ID, $args = array() ) { 'type' => $args['type'], 'post_id' => $comment->comment_post_ID, 'fields' => 'ids', + 'count' => true, 'status' => 'approve', 'date_query' => array( array( @@ -888,8 +889,8 @@ function get_page_of_comment( $comment_ID, $args = array() ) { ), ); - $older_comment_ids = get_comments( $comment_args ); - $older_comment_count = count( $older_comment_ids ); + $comment_query = new WP_Comment_Query(); + $older_comment_count = $comment_query->query( $comment_args ); // No older comments? Then it's page #1. if ( 0 == $older_comment_count )