[wp-trac] [WordPress Trac] #15961: WP_Comments_List_Table causes get_pending_comments_num to run a lame query

WordPress Trac wp-trac at lists.automattic.com
Thu Dec 23 10:15:50 UTC 2010


#15961: WP_Comments_List_Table causes get_pending_comments_num to run a lame query
--------------------------+-----------------------------
 Reporter:  westi         |       Owner:  westi
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Comments      |     Version:  3.1
 Severity:  normal        |  Resolution:
 Keywords:  3.2-early     |
--------------------------+-----------------------------
Description changed by westi:

Old description:

> In WP_Comments_List_Table::prepare_items we call get_comments to get the
> comments for the current view.
>
> We then loop through the comments to build an array of post_ids.
>
> We then call get_pending_comments_num with this array of ids.
>
> At no point does prepare_items or get_pending_comments_num do any thing
> to the array to ensure uniqueness.
>
> Therefore we run queries like this:
>
> {{{SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM
> wp__comments WHERE comment_post_ID IN ( '627', '627', '1', '5', '1',
> '20', '40', '30', '20', '10', '10', '627', '627', '627', '627', '627',
> '627', '627', '627', '627' ) AND comment_approved = '0' GROUP BY
> comment_post_ID
> }}}

New description:

 In WP_Comments_List_Table::prepare_items we call get_comments to get the
 comments for the current view.

 We then loop through the comments to build an array of post_ids.

 We then call get_pending_comments_num with this array of ids.

 At no point does prepare_items or get_pending_comments_num do any thing to
 the array to ensure uniqueness.

 Therefore we run queries like this:

 {{{
 SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM
 wp__comments WHERE comment_post_ID IN ( '627', '627', '1', '5', '1', '20',
 '40', '30', '20', '10', '10', '627', '627', '627', '627', '627', '627',
 '627', '627', '627' ) AND comment_approved = '0' GROUP BY comment_post_ID
 }}}

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15961#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list