* Defer message cache initialization, shaving a few ms off file cache hits
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 9 Dec 2004 05:51:20 +0000 (05:51 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 9 Dec 2004 05:51:20 +0000 (05:51 +0000)
includes/Article.php
includes/MessageCache.php
includes/Parser.php
includes/Setup.php
includes/Skin.php
index.php
languages/Language.php

index 0ad959c..42a368f 100644 (file)
@@ -1956,11 +1956,6 @@ class Article {
                $called = true;
                if($this->isFileCacheable()) {
                        $touched = $this->mTouched;
-                       if( $this->mTitle->getPrefixedDBkey() == wfMsg( 'mainpage' ) ) {
-                               # Expire the main page quicker
-                               $expire = wfUnix2Timestamp( time() - 3600 );
-                               $touched = max( $expire, $touched );
-                       }
                        $cache = new CacheManager( $this->mTitle );
                        if($cache->isFileCacheGood( $touched )) {
                                global $wgOut;
index 8d868ec..714f462 100755 (executable)
@@ -23,6 +23,7 @@ class MessageCache
        var $mMemcKey, $mKeys, $mParserOptions, $mParser;
        var $mExtensionMessages;
        var $mInitialised = false;
+       var $mDeferred = true;
 
        function initialise( &$memCached, $useDB, $expiry, $memcPrefix) {
                $fname = 'MessageCache::initialise';
@@ -44,7 +45,12 @@ class MessageCache
                $this->mParser = new Parser;
                wfProfileOut( $fname.'-parser' );
 
-               $this->load();
+               # When we first get asked for a message,
+               # then we'll fill up the cache. If we
+               # can return a cache hit, this saves
+               # some extra milliseconds
+               $this->mDeferred = true;
+               
                wfProfileOut( $fname );
        }
 
@@ -113,6 +119,7 @@ class MessageCache
                        }
                }
                wfProfileOut( $fname );
+               $this->mDeferred = false;
                return $success;
        }
 
@@ -221,6 +228,10 @@ class MessageCache
                if( !$this->mInitialised ) {
                        return "&lt;$key&gt;";
                }
+               # If cache initialization was deferred, start it now.
+               if( $this->mDeferred ) {
+                       $this->load();
+               }
 
                $message = false;
                if( !$this->mDisable && $useDB ) {
index 0e911d6..17c52ad 100644 (file)
@@ -959,7 +959,9 @@ class Parser
                wfProfileIn( $fname );
 
                $sk =& $this->mOptions->getSkin();
-               $linktrail = wfMsgForContent('linktrail');
+               global $wgContLang;
+               $linktrail = $wgContLang->linkTrail();
+               
                $bits = preg_split( EXT_LINK_BRACKETED, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
 
                $s = $this->replaceFreeExternalLinks( array_shift( $bits ) );
index d609498..aa9fa0d 100644 (file)
@@ -358,7 +358,7 @@ $wgMsgParserOptions = ParserOptions::newFromUser($wgUser);
 wfSeedRandom();
 
 # Placeholders in case of DB error
-$wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
+$wgTitle = Title::makeTitle( NS_SPECIAL, 'Error' );
 $wgArticle = new Article($wgTitle);
 
 wfProfileOut( $fname.'-misc2' );
index c114af1..4978cdb 100644 (file)
@@ -83,7 +83,8 @@ class Skin {
        /**#@-*/
 
        function Skin() {
-               $this->linktrail = wfMsgForContent('linktrail');
+               global $wgContLang;
+               $this->linktrail = $wgContLang->linkTrail();
                
                # Cache option lookups done very frequently
                $options = array( 'highlightbroken', 'hover' );
index 1de2977..5486408 100644 (file)
--- a/index.php
+++ b/index.php
@@ -31,10 +31,6 @@ OutputPage::setEncodings(); # Not really used yet
 $action = $wgRequest->getVal( "action", "view" );
 $title = $wgRequest->getVal( "title" );
 
-# Placeholders in case of DB error
-$wgTitle = Title::newFromText( wfMsgForContent( "badtitle" ) );
-$wgArticle = new Article($wgTitle);
-
 $action = strtolower( trim( $action ) );
 if ($wgRequest->getVal( "printable" ) == "yes") {
        $wgOut->setPrintable();
index cf4c1ea..87c67c3 100644 (file)
@@ -2230,6 +2230,20 @@ class Language {
        function getExtraHashOptions() {
                return array();
        }
+       
+       /**
+        * A regular expression to match legal word-trailing characters
+        * which should be merged onto a link of the form [[foo]]bar.
+        * FIXME
+        *
+        * @return string
+        * @access public
+        */
+       function linkTrail() {
+               $trail = $this->getMessage( 'linktrail' );
+               if( empty( $trail ) ) $trail = Language::linkTrail();
+               return $trail;
+       }
 
 }