Object return type hints
[lhc/web/wiklou.git] / includes / ChangesFeed.php
index 69a285e..f07b650 100644 (file)
@@ -27,8 +27,8 @@ class ChangesFeed {
         * @return ChannelFeed subclass or false on failure
         */
        public function getFeedObject( $title, $description ) {
-               global $wgSitename, $wgContLanguageCode, $wgFeedClasses, $wgTitle;
-               $feedTitle = "$wgSitename  - {$title} [$wgContLanguageCode]";
+               global $wgSitename, $wgLanguageCode, $wgFeedClasses, $wgTitle;
+               $feedTitle = "$wgSitename  - {$title} [$wgLanguageCode]";
                if( !isset($wgFeedClasses[$this->format] ) )
                        return false;
                return new $wgFeedClasses[$this->format](
@@ -40,25 +40,22 @@ class ChangesFeed {
         *
         * @param $feed ChannelFeed subclass object (generally the one returned by getFeedObject())
         * @param $rows ResultWrapper object with rows in recentchanges table
-        * @param $limit Integer: number of rows in $rows (only used for the cache key)
-        * @param $hideminor Boolean: whether to hide minor edits (only used for the cache key)
         * @param $lastmod Integer: timestamp of the last item in the recentchanges table (only used for the cache key)
-        * @param $target String: target's name; for Special:RecentChangesLinked (only used for the cache key)
-        * @param $namespace Integer: namespace id (only used for the cache key)
+        * @param $opts FormOptions as in SpecialRecentChanges::getDefaultOptions()
         * @return null or true
         */
-       public function execute( $feed, $rows, $limit=0, $hideminor=false, $lastmod=false, $target='', $namespace='' ) {
-               global $messageMemc, $wgFeedCacheTimeout;
-               global $wgSitename, $wgLang;
+       public function execute( $feed, $rows, $lastmod, $opts ) {
+               global $wgLang, $wgRenderHashAppend;
 
                if ( !FeedUtils::checkFeedOutput( $this->format ) ) {
                        return;
                }
 
-               $timekey = wfMemcKey( $this->type, $this->format, 'timestamp' );
-               $key = wfMemcKey( $this->type, $this->format, $limit, $hideminor, $target, $wgLang->getCode(), $namespace );
+               $optionsHash = md5( serialize( $opts->getAllValues() ) ) . $wgRenderHashAppend;
+               $timekey = wfMemcKey( $this->type, $this->format, $wgLang->getCode(), $optionsHash, 'timestamp' );
+               $key = wfMemcKey( $this->type, $this->format, $wgLang->getCode(), $optionsHash );
 
-               FeedUtils::checkPurge($timekey, $key);
+               FeedUtils::checkPurge( $timekey, $key );
 
                /*
                * Bumping around loading up diffs can be pretty slow, so where
@@ -104,7 +101,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 ) {
@@ -121,6 +119,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" );
@@ -173,4 +174,4 @@ class ChangesFeed {
                wfProfileOut( __METHOD__ );
        }
 
-}
\ No newline at end of file
+}