[wp-trac] [WordPress Trac] #15905: Using wp_list_comments using both the type and callback arguments causes the first comment to be repeated

WordPress Trac wp-trac at lists.automattic.com
Tue Dec 28 21:09:26 UTC 2010


#15905: Using wp_list_comments using both the type and callback arguments causes
the first comment to be repeated
--------------------------+-----------------------------
 Reporter:  benschell     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Comments      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+-----------------------------
Changes (by benschell):

 * cc: ben@… (added)


Comment:

 I've narrowed this bug down but, since this is my first foray into the
 core of Wordpress, I'm not exactly sure where the fix should be applied.

 In this specific use case, I'm calling wp_list_comments on an index page;
 that is, I'm doing a loop, calling the_post() in each loop, then calling
 wp_list_comments() while displaying each post to present its comments.
 Between source:trunk/wp-includes/comment-template.php#L1426 and L1450, the
 set of comments that should be displayed is determined.  When the 'type'
 argument is set, $wp_query->comments_by_type is checked and used if
 present.  If not, $wp_query->comments is separated into type (by
 separate_comments()), stored at $wp_query->comments_by_type, and that
 outcome used for display.

 The bug is in this use of $wp_query->comments_by_type; when the_post() is
 called, $wp_query->comments is reset but $wp_query->comments_by_type is
 not.  So, when the next post is displayed and wp_list_comments() is
 called, $wp_query->comments_by_type is not empty, but is invalid as it
 contains the comments from the previous post.

 I'm not sure that $wp_query->comments_by_type should be reset in query.php
 (when $wp_query->comments is set) since the only use (in core) of
 comments_by_type is in comment-template.php.  Other than storing
 additional information (what post comments_by_type came from) or not
 caching the result of separate_comments on $wp_query, I can't figure out a
 good way to patch comment-template.php .  But, maybe this analysis will
 help the proper maintainer come up with a patch? I'm happy to come up with
 a patch and/or provide testing assistance if the appropriate maintainer
 has a preference/suggestion on how this should be fixed.

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


More information about the wp-trac mailing list