WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#29685 closed defect (bug) (invalid)

WP_Comments_List_Table total_comments count wrong when using meta_query

Reported by: ragulka Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Comments Keywords:
Focuses: administration, performance Cc:
PR Number:

Description

When a meta_query is used to fetch comments in the WP_Comments_List_Table, the $total_comments will always return 1, and not the correct number of total comments found.

This is because the total count is queried using COUNT (*) and the WP_Comment_Query query method
automatically adds GROUP BY {$wpdb->comments}.comment_ID to the query. This results in the query returning multiple rows, each with the count of 1.

Removing the GROUP BY clause seems to fix the problem, although I'm not sure if there can be any other adverse effects to this.

It seems that when querying the total count of posts on the edit-posts screen, SQL_CALC_FOUND_ROWS is used instead. I'm not sure if we want to use that approach or simply remove the GROUP BY clause. Or perhaps there is a third option?

Change History (3)

#1 @dd32
5 years ago

  • Summary changed from WC_Comments_List_Table total_comments count wrong when using meta_query to WP_Comments_List_Table total_comments count wrong when using meta_query

#2 @tyxla
4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

This has already been fixed in [30026], see #23369.

#3 @netweb
4 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.