#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: |
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?
This has already been fixed in [30026], see #23369.