* Move filecache hits to faster lower level index.php code
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 27 Dec 2008 07:07:16 +0000 (07:07 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 27 Dec 2008 07:07:16 +0000 (07:07 +0000)
* Disable outputpage after file cache hit, since output was streamed already.

includes/Wiki.php
index.php

index 00fd407..9bb54c3 100644 (file)
@@ -111,7 +111,6 @@ class MediaWiki {
                        // about the possible different language variants
                        if( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 )
                                $wgContLang->findVariantLink( $title, $ret );
-
                }
                if( ( $oldid = $wgRequest->getInt( 'oldid' ) )
                        && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
@@ -221,25 +220,6 @@ class MediaWiki {
                        /* actions that need to be made when we have a special pages */
                        SpecialPage::executePath( $title );
                } else {
-                       /* Try low-level file cache hit */
-                       if( $title->getNamespace() != NS_MEDIAWIKI && HTMLFileCache::useFileCache() ) {
-                               $cache = new HTMLFileCache( $title );
-                               if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
-                                       global $wgOut;
-                                       /* Check incoming headers to see if client has this cached */
-                                       if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
-                                               wfDebug( "MediaWiki::initializeSpecialCases(): about to load file cache\n" );
-                                               $cache->loadFromFileCache();
-                                               # Tell $wgOut that output is taken care of
-                                               $wgOut->disable();
-                                               # Do any stats increment/watchlist stuff
-                                               $article = self::articleFromTitle( $title );
-                                               $article->viewUpdates();
-                                       }
-                                       wfProfileOut( __METHOD__ );
-                                       return true;
-                               }
-                       }
                        /* No match to special cases */
                        wfProfileOut( __METHOD__ );
                        return false;
index 8858579..22e74e9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -67,13 +67,35 @@ wfProfileOut( 'main-misc-setup' );
 #
 if( $wgUseAjax && $action == 'ajax' ) {
        require_once( $IP . '/includes/AjaxDispatcher.php' );
-
        $dispatcher = new AjaxDispatcher();
        $dispatcher->performAction();
        $mediaWiki->restInPeace();
        exit;
 }
 
+if( $wgUseFileCache && isset($wgTitle) ) {
+       wfProfileIn( 'main-try-filecache' );
+       if( HTMLFileCache::useFileCache() ) {
+               /* Try low-level file cache hit */
+               $cache = new HTMLFileCache( $wgTitle );
+               if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
+                       /* Check incoming headers to see if client has this cached */
+                       if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
+                               $cache->loadFromFileCache();
+                               # Do any stats increment/watchlist stuff
+                               $wgArticle = self::articleFromTitle( $wgTitle );
+                               $wgArticle->viewUpdates();
+                       }
+                       # Tell $wgOut that output is taken care of
+                       $wgOut->disable();
+                       wfProfileOut( 'main-try-filecache' );
+                       $mediaWiki->restInPeace();
+                       exit;
+               }
+       }
+       wfProfileOut( 'main-try-filecache' );
+}
+
 # Setting global variables in mediaWiki
 $mediaWiki->setVal( 'action', $action );
 $mediaWiki->setVal( 'CommandLineMode', $wgCommandLineMode );
@@ -89,7 +111,7 @@ $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
 
 $mediaWiki->initialize( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
-$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgOut );
+$mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
 
 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
 $mediaWiki->doUpdates( $wgPostCommitUpdateList );