[wp-trac] [WordPress Trac] #29685: WC_Comments_List_Table total_comments count wrong when using meta_query
WordPress Trac
noreply at wordpress.org
Tue Sep 16 12:27:50 UTC 2014
#29685: WC_Comments_List_Table total_comments count wrong when using meta_query
-----------------------------------------+-----------------------------
Reporter: ragulka | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 3.9
Severity: normal | Keywords:
Focuses: administration, performance |
-----------------------------------------+-----------------------------
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
[https://github.com/WordPress/WordPress/blob/master/wp-
includes/comment.php#L434-L439 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?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29685>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list