http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97981

Revision: 97981
Author:   aaron
Date:     2011-09-24 01:17:04 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
Added filecache support for history pages

Modified Paths:
--------------
    trunk/phase3/includes/HistoryPage.php
    trunk/phase3/includes/cache/HTMLFileCache.php

Modified: trunk/phase3/includes/HistoryPage.php
===================================================================
--- trunk/phase3/includes/HistoryPage.php       2011-09-24 00:55:49 UTC (rev 
97980)
+++ trunk/phase3/includes/HistoryPage.php       2011-09-24 01:17:04 UTC (rev 
97981)
@@ -64,16 +64,25 @@
         * @return nothing
         */
        function history() {
-               global $wgOut, $wgRequest, $wgScript;
+               global $wgOut, $wgRequest, $wgScript, $wgUseFileCache;
 
                /**
                 * Allow client caching.
                 */
-               if ( $wgOut->checkLastModified( $this->article->getTouched() ) )
+               if ( $wgOut->checkLastModified( $this->article->getTouched() ) 
) {
                        return; // Client cache fresh and headers sent, nothing 
more to do.
+               }
 
                wfProfileIn( __METHOD__ );
 
+               # Fill in the file cache if not set already
+               if ( $wgUseFileCache && HTMLFileCache::useFileCache() ) {
+                       $cache = new HTMLFileCache( $this->title, 'history' );
+                       if ( !$cache->isFileCacheGood( /* Assume up to date */ 
) ) {
+                               ob_start( array( &$cache, 'saveToFileCache' ) );
+                       }
+               }
+
                // Setup page variables.
                $wgOut->setPageTitle( wfMsg( 'history-title', 
$this->title->getPrefixedText() ) );
                $wgOut->setPageTitleActionText( wfMsg( 'history_short' ) );

Modified: trunk/phase3/includes/cache/HTMLFileCache.php
===================================================================
--- trunk/phase3/includes/cache/HTMLFileCache.php       2011-09-24 00:55:49 UTC 
(rev 97980)
+++ trunk/phase3/includes/cache/HTMLFileCache.php       2011-09-24 01:17:04 UTC 
(rev 97981)
@@ -29,10 +29,14 @@
 
        public function __construct( $title, $type = 'view' ) {
                $this->mTitle = $title;
-               $this->mType = ( $type == 'view' ) ? $type : false;
+               $this->mType = in_array( $type, self::cacheableActions() ) ? 
$type : false;
                $this->fileCacheName(); // init name
        }
 
+       protected static function cacheableActions() {
+               return array( 'view', 'history' );
+       }
+
        public function fileCacheName() {
                if( !$this->mFileCache ) {
                        global $wgCacheDirectory, $wgFileCacheDirectory, 
$wgFileCacheDepth;
@@ -95,7 +99,7 @@
                                continue; // note: curid sets title
                        // Normal page view in query form can have action=view.
                        // Raw hits for pages also stored, like .css pages for 
example.
-                       } elseif( $query == 'action' && $val == 'view' ) {
+                       } elseif( $query == 'action' && in_array( $val, 
self::cacheableActions() ) ) {
                                continue;
                        // Below are header setting params
                        } elseif( $query == 'maxage' || $query == 'smaxage' ) {
@@ -229,10 +233,10 @@
                }
 
                wfSuppressWarnings();
-
-               $fc = new self( $title, 'view' );
-               unlink( $fc->fileCacheName() );
-
+               foreach( self::cacheableActions() as $type ) {
+                       $fc = new self( $title, $type );
+                       unlink( $fc->fileCacheName() );
+               }
                wfRestoreWarnings();
 
                return true;


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to