Ticket #137 (closed defect: fixed)

Opened 4 years ago

Last modified 2 years ago

Comments feed modification time is based on posts, not comments

Reported by: kelson Assigned to: ryan
Priority: normal Milestone: 2.1
Component: General Version: 2.0
Severity: minor Keywords: has-patch, needs-testing
Cc:

Description

When determining the last-modified date for the comments feed, WP only checks the latest modification of the posts, not comments. As a result, if there's a new comment but not a new post, it uses the older time and will give aggregators a "Not Modified" response.

Attachments

0000137-comments_feed_modtime.patch (2.5 kB) - added by kelson on 05/21/05 06:27:10.
comments-feed-last-modified.patch (0.6 kB) - added by chrisdolan on 11/30/05 16:58:42.
Update to support feed=comments-rss2
last-modified-comments.patch (441 bytes) - added by colinleroy on 01/12/06 13:00:37.
Same patch, not broken as in the my comment
137.diff (2.6 kB) - added by mdawaffe on 11/08/06 23:11:06.

Change History

07/01/04 23:28:17 changed by kelson

07/02/04 18:39:51 changed by hugo

Here is the getlastcommentmodified function. It is based on the lastpostmodified function. It only looks at post_date_gmt and post_date.

function get_lastcommentmodified($timezone = 'server') {

global $tablecomments, $cache_lastcommentmodified, $pagenow, $wpdb; $add_seconds_blog = get_settings('gmt_offset') * 3600; $add_seconds_server = date('Z'); $now = current_time('mysql', 1); if ( !isset($cache_lastcommentmodified[$timezone]) ) {

switch(strtolower($timezone)) {

case 'gmt':

$lastcommentmodified = $wpdb->get_var("SELECT co

mment_date_gmt FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY com ment_date_gmt DESC LIMIT 1");

break;

case 'blog':

$lastcommentmodified = $wpdb->get_var("SELECT co

mment_date FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment _date_gmt DESC LIMIT 1");

break;

case 'server':

$lastcommentmodified = $wpdb->get_var("SELECT DA

TE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tablecomme nts WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");

break;

} $cache_lastcommentmodified[$timezone] = $lastcommentmodified;

} else {

$lastcommentmodified = $cache_lastcommentmodified[$timezone];

} return $lastcommentmodified;

}

07/02/04 18:41:29 changed by hugo

You have to additionally use get_lastcommentmodified in wp_blog_header.php as follows:

if ($withcomments) {

$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcomment

modified('GMT'), 0).' GMT';

} else {

$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmod

ified('GMT'), 0).' GMT';

}

And you need to do the "move exit out of ifs" from the bug 133 to make 304 status usefull. And you need to set $withcomments = 1 in wp-commentsrss2.php directly before the require for wp-blog-header.

07/15/04 19:18:11 changed by kelson

The function hugo posted seems to work. I added it and changed the call in wp-blog-header.php on the 2nd, and it's been working fine since then. It even handles the case where I go in and edit a recent comment.

09/14/04 22:51:30 changed by anonymousbugger

Is anyone doing anything with this? It's been two months since the last post, and that was me reporting that the fix suggested here had been working fine on my site for the previous several weeks.

Without this fix, no one will see updates to the comments feed until you post a new article.

10/14/04 05:35:09 changed by kelson

There's been a working fix for this for 3 months and no activity. (And apparently no owner?) On the theory that what's holding it up is the lack of a patch... here's a patch.

I should mention that the severity is higher now than it originally was, because it used to be masked by bug 133. Now that that's fixed, this becomes an issue. If you only post once a week, but several people comment each day, your comments feed will not update for the entire week.

10/14/04 08:29:42 changed by matt

  • owner changed from anonymous to matt.
  • status changed from new to closed.
  • resolution changed from 10 to 20.

12/09/04 01:31:15 changed by 2fargon

  • status changed from closed to closed.

05/21/05 06:27:10 changed by kelson

  • attachment 0000137-comments_feed_modtime.patch added.

11/30/05 16:58:42 changed by chrisdolan

  • attachment comments-feed-last-modified.patch added.

Update to support feed=comments-rss2

11/30/05 17:08:13 changed by chrisdolan

  • status changed from closed to reopened.
  • version changed from 1.2 to 1.5.2.
  • resolution deleted.

(note: this is against the 1.5.2 branch. I'm not working on the SVN trunk. Apologies if this is consequently out of date)

This is broken in v1.5.2 when used with the index.php?feed=comments-rss2 URL (not with the index.php/comments/feed/ URL). I just attached a very crude patch that fixes the problem. A more sophisticated patch would either deprecate the feed=comments-rss2 URL or build that into the $withcomments flag.

01/12/06 12:59:58 changed by colinleroy

I have this problem with wp 2.0. Using the permalink to a post's commentRSS feed, in the following form: http://$website/$wp-base/archives/2005/12/21/$post-name/feed/ , the variable withcomments isn't set and hence, the Last-Modified header doesn't use the latest comment's date.

Here's the patch I use to fix it: Index: wp-includes/classes.php =================================================================== --- wp-includes/classes.php (revision 3428) +++ wp-includes/classes.php (working copy) @@ -1575,6 +1575,10 @@

$this->did_permalink = false;

}

+ + if ($query_varsname? && $query_varsfeed?) + $query_varswithcomments?=1; +

}

$this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);

====================================================================

01/12/06 13:00:37 changed by colinleroy

  • attachment last-modified-comments.patch added.

Same patch, not broken as in the my comment

04/24/06 03:59:47 changed by leftjustified

  • cc deleted.
  • keywords set to bg|has-patch, bg|needs-testing.
  • version changed from 1.5.2 to 2.0.

Trying to clean up the 'needs-patch' category :)

08/30/06 05:44:25 changed by ryan

  • owner changed from matt to ryan.
  • status changed from reopened to new.

09/26/06 00:41:29 changed by foolswisdom

  • keywords changed from bg|has-patch, bg|needs-testing to has-patch, needs-testing.
  • milestone set to 2.1.

11/08/06 23:11:06 changed by mdawaffe

  • attachment 137.diff added.

11/08/06 23:13:26 changed by mdawaffe

137.diff

  1. adds 'withoutcomments' query var
  2. send_headers() checks last modified comment if withcomments or if !withoutcomments and one of the is_sigular query vars is set.

11/18/06 20:46:46 changed by ryan

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

(In [4483]) Base last modified time for comment feeds on comments, not the post. Props mdawaffe. fixes #137