Skip to content

Commit

Permalink
Merge pull request #2903 from 10up/fix/issue-2897-comment-count
Browse files Browse the repository at this point in the history
Comments: Make a proper count call instead of counting the results
  • Loading branch information
felipeelia authored Jul 26, 2022
2 parents 836b06f + ba8b992 commit 4c65448
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions includes/classes/Indexable/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,18 +882,17 @@ public function query_db( $args ) {

unset( $all_query_args['number'] );
unset( $all_query_args['offset'] );
$all_query_args['count'] = true;

/**
* Filter database arguments for term count query
* Filter database arguments for comment count query
*
* @hook ep_comment_all_query_db_args
* @param {array} $args Query arguments based to WP_Comment_Query
* @since 3.6.0
* @return {array} New arguments
*/
$all_query = new WP_Comment_Query( apply_filters( 'ep_comment_all_query_db_args', $all_query_args, $args ) );

$total_objects = count( $all_query->comments );
$total_objects = get_comments( apply_filters( 'ep_comment_all_query_db_args', $all_query_args, $args ) );

if ( ! empty( $args['offset'] ) ) {
if ( (int) $args['offset'] >= $total_objects ) {
Expand Down

0 comments on commit 4c65448

Please sign in to comment.