From 5fea872d38e56ab93e1a8f6c348131c690a9e05b Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 5 Apr 2010 16:14:58 +0000 Subject: [PATCH] * (bug 21916) Last-Modified header is now correct when outputting cached feed --- RELEASE-NOTES | 1 + includes/ChangesFeed.php | 6 +++++- includes/OutputPage.php | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1898b05847..4130f2f598 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -84,6 +84,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 22496) Viewing diff of a redirect page without specifying "oldid" parameter no longer makes the page displayed as being the redirect target * (bug 22918) Feed cache keys now use $wgRenderHashAppend +* (bug 21916) Last-Modified header is now correct when outputting cached feed === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent diff --git a/includes/ChangesFeed.php b/includes/ChangesFeed.php index 1cc18d300d..4a5a2d16d2 100644 --- a/includes/ChangesFeed.php +++ b/includes/ChangesFeed.php @@ -102,7 +102,8 @@ class ChangesFeed { * @return feed's content on cache hit or false on cache miss */ public function loadFromCache( $lastmod, $timekey, $key ) { - global $wgFeedCacheTimeout, $messageMemc; + global $wgFeedCacheTimeout, $wgOut, $messageMemc; + $feedLastmod = $messageMemc->get( $timekey ); if( ( $wgFeedCacheTimeout > 0 ) && $feedLastmod ) { @@ -119,6 +120,9 @@ class ChangesFeed { if( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix) { wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" ); + if ( $feedLastmodUnix < $lastmodUnix ) { + $wgOut->setLastModified( $feedLastmod ); // bug 21916 + } return $messageMemc->get( $key ); } else { wfDebug( "RC: cached feed timestamp check failed ($feedLastmod; $lastmod)\n" ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b88862b45b..eec5620b93 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -364,6 +364,16 @@ class OutputPage { return true; } + /** + * Override the last modified timestamp + * + * @param $timestamp String: new timestamp, in a format readable by + * wfTimestamp() + */ + public function setLastModified( $timestamp ) { + $this->mLastModified = wfTimestamp( TS_RFC2822, $timestamp ); + } + /** * Set the robot policy for the page: -- 2.20.1