Ticket #5439 (closed defect: worksforme)

Opened 7 months ago

Last modified 5 months ago

page displaying wrong comments

Reported by: dcostalis Assigned to: anonymous
Priority: normal Milestone:
Component: Template Version: 2.3.1
Severity: normal Keywords: comments has-patch widgets 2nd-opinion
Cc:

Description

Depending on how widgets are set up, and the layout of the page, WordPress may display the wrong comments for a post.

The widget.php file uses a variable $id, which is used frequently throughout code. That variable is not unset, and moving the sidebar code above the comment code while this widget is active will cause the comments_template function to instead display comments from the last post on the "recent posts" list. solution proposed.

Attachments

widgets.php[1].diff (310 bytes) - added by dcostalis on 12/07/07 19:08:44.
updated proposed fix
fix_comments_query.patch (388 bytes) - added by ionfish on 01/16/08 12:24:49.
reset_query.diff (0.8 kB) - added by ryan on 01/16/08 17:25:27.
reset_query.2.diff (0.8 kB) - added by ryan on 01/23/08 16:52:56.
recent_query_3.diff (433 bytes) - added by ionfish on 01/24/08 19:36:53.

Change History

12/07/07 19:08:44 changed by dcostalis

  • attachment widgets.php[1].diff added.

updated proposed fix

12/07/07 20:16:06 changed by ionfish

Tarski hacks around this issue by adding the following code below the sidebar widgets block, but it would be much better if this weren't necessary.

$wp_the_query->current_post--;
setup_postdata($wp_query->next_post());

12/23/07 12:55:08 changed by ionfish

  • keywords changed from comments to comments needs-patch.

Patch from 12/07/07 doesn't work for me. Included post reset does fix it, but obviously ideally the widgets code would be better isolated from the page or post loop.

01/16/08 12:24:49 changed by ionfish

  • attachment fix_comments_query.patch added.

01/16/08 12:26:30 changed by ionfish

  • keywords changed from comments needs-patch to comments has-patch widgets 2nd-opinion.
  • component changed from General to Template.

Added a patch that seems to fix this.

01/16/08 17:25:27 changed by ryan

  • attachment reset_query.diff added.

01/16/08 17:26:18 changed by ryan

How about having wp_reset_query() reset the global post data? See patch (untested).

01/19/08 02:21:22 changed by ryan

Does that patch work for anyone?

01/23/08 15:19:42 changed by ionfish

Sorry, been a really busy week. Having just tested this, it doesn't seem to fix my Tarski issue. I commented out the hack I mentioned above, applied the hack, and found all my posts getting the same comments, from the last article on the 'Recent Articles' widget list.

01/23/08 16:52:56 changed by ryan

  • attachment reset_query.2.diff added.

01/23/08 16:53:10 changed by ryan

Maybe that will work better.

01/24/08 19:36:53 changed by ionfish

  • attachment recent_query_3.diff added.

01/24/08 19:37:17 changed by ionfish

Doesn't work... but this does.

01/25/08 01:41:57 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6653]) Restore global post when resetting the query. Props ionfish. fixes #5439

01/29/08 23:58:42 changed by ryan

(In [6688]) Don't advance post counter when resetting query. see #5439

01/30/08 00:01:23 changed by ryan

  • status changed from closed to reopened.
  • resolution deleted.

Using next_post() causes problems with other themes. Reverting and reopening.

01/30/08 09:37:32 changed by ionfish

  • status changed from reopened to closed.
  • resolution set to worksforme.
  • milestone deleted.

#6687 has resolved this for me.

01/30/08 09:38:21 changed by ionfish

[6687], rather.