* (bug 21916) Last-Modified header is now correct when outputting cached feed
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 5 Apr 2010 16:14:58 +0000 (16:14 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 5 Apr 2010 16:14:58 +0000 (16:14 +0000)
RELEASE-NOTES
includes/ChangesFeed.php
includes/OutputPage.php

index 1898b05..4130f2f 100644 (file)
@@ -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
index 1cc18d3..4a5a2d1 100644 (file)
@@ -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" );
index b88862b..eec5620 100644 (file)
@@ -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: <http://www.robotstxt.org/meta.html>