Opened 15 years ago
Closed 10 years ago
#14809 closed defect (bug) (fixed)
comments_by_type doesn't always get reset
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | minor | Version: | 3.0.1 |
Component: | Comments | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
in wp-includes/comment-template.php , in function comments_template(), it is possible for $wp_query->comments to be set but for $wp_query->comments_by_type NOT to get reset when it should be reset to array(). We ran into a bug because:
- on a single page (actually inside of a widget), we were pulling comments from multiple posts
- for each post, we were requesting get_comments(array('type' => 'comment'))
- in wp-includes/comment-template.php , in function wp_list_comments(), code says:
if ( 'all' != $r['type'] ) { if ( empty($wp_query->comments_by_type) ) $wp_query->comments_by_type = &separate_comments($wp_query->comments); if ( empty($wp_query->comments_by_type[$r['type']]) ) return; $_comments = $wp_query->comments_by_type[$r['type']];
unfortunately, since we were running that again and again, it would not recalculate $wp_query->comments_by_type each time.
I think that the function comments_template() in wp-includes/comment-template.php should have the following line added:
$wp_query->comments_by_type = array();
right after the line where $wp_query->comments is set.
Attachments (1)
Change History (9)
Note: See
TracTickets for help on using
tickets.
I'm a bit confused here - if you were using
get_comments()
for each post and then supplying those as an argument towp_list_comments()
, the lines of code containing$wp_query->comments_by_type
would never be invoked - they only get used if you don't supply your own list of comments.Could you post the code you're using for
get_comments()
andwp_list_comments()
in the loop?