Ticket #137 (closed defect (bug): fixed)
Comments feed modification time is based on posts, not comments
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| 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
Change History
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;
}
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.
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.
comment:5
anonymousbugger — 7 years ago
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.
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.
- Owner changed from anonymous to matt
- Status changed from new to closed
- Resolution changed from 10 to 20
chrisdolan — 6 years ago
-
attachment
comments-feed-last-modified.patch
added
Update to support feed=comments-rss2
comment:9
chrisdolan — 6 years ago
- Status changed from closed to reopened
- Version changed from 1.2 to 1.5.2
- Resolution fixed 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.
comment:10
colinleroy — 6 years ago
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);
====================================================================
colinleroy — 6 years ago
-
attachment
last-modified-comments.patch
added
Same patch, not broken as in the my comment
comment:11
leftjustified — 6 years ago
- Cc hugo removed
- Keywords bg|has-patch, bg|needs-testing added
- Version changed from 1.5.2 to 2.0
Trying to clean up the 'needs-patch' category :)
comment:13
foolswisdom — 5 years ago
- Keywords has-patch, needs-testing added; bg|has-patch, bg|needs-testing removed
- Milestone set to 2.1
comment:14
mdawaffe — 5 years ago
137.diff
- adds 'withoutcomments' query var
- send_headers() checks last modified comment if withcomments or if !withoutcomments and one of the is_sigular query vars is set.
comment:15
ryan — 5 years ago
- Status changed from new to closed
- Resolution set to fixed
