* Replaced $wgMessageCache by MessageCache::singleton(); since we only use one instan...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 26 Jan 2011 15:42:04 +0000 (15:42 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Wed, 26 Jan 2011 15:42:04 +0000 (15:42 +0000)
* MessageCache::singleton() calls wfGetMessageCacheStorage() directly instead of using $messageMemc, just in case this would be called before that variable is set
* Per TimStarling: also removed deprecated methods in MessageCache class: addMessages() and related, [get|set|enable|disable]Transform(), loadAllMessages(), loadMessageFile() and some others. Same for the legacyData stuff in LocalisationCache that was only used by MessageCache::addMessages() and related.
* Converted remaining extensions

18 files changed:
docs/globals.txt
includes/Article.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/LocalisationCache.php
includes/Message.php
includes/MessageCache.php
includes/Setup.php
includes/Title.php
includes/db/Database.php
includes/parser/CoreParserFunctions.php
languages/LanguageConverter.php
tests/parser/parserTest.inc
tests/phpunit/bootstrap.php
tests/phpunit/includes/MessageTest.php
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/parser/NewParserTest.php
tests/phpunit/suites/UploadFromUrlTestSuite.php

index 46486dd..bb3b294 100644 (file)
@@ -68,6 +68,3 @@ $wgRequest
 
 $wgMemc, $messageMemc, $parserMemc
        Object caches
-
-$wgMessageCache
-       Message cache, to manage interface messages
index 44bd713..726797e 100644 (file)
@@ -249,7 +249,7 @@ class Article {
         * @return Return the text of this revision
         */
        public function getContent() {
-               global $wgUser, $wgContLang, $wgMessageCache;
+               global $wgUser, $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
@@ -258,7 +258,7 @@ class Article {
                        # and return the message value for x.
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                                # If this is a system message, get the default text.
-                               list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
+                               list( $message, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
                                $text = wfMsgGetKey( $message, false, $lang, false );
 
                                if ( wfEmptyMsg( $message, $text ) )
@@ -1712,15 +1712,13 @@ class Article {
                }
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                       global $wgMessageCache;
-
                        if ( $this->getID() == 0 ) {
                                $text = false;
                        } else {
                                $text = $this->getRawText();
                        }
 
-                       $wgMessageCache->replace( $this->mTitle->getDBkey(), $text );
+                       MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text );
                }
        }
 
@@ -3632,7 +3630,7 @@ class Article {
         * @param $user User object: User doing the edit
         */
        public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true, User $user = null ) {
-               global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgEnableParserCache;
+               global $wgDeferredUpdateList, $wgUser, $wgEnableParserCache;
 
                wfProfileIn( __METHOD__ );
 
@@ -3710,7 +3708,7 @@ class Article {
                }
 
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                       $wgMessageCache->replace( $shortTitle, $text );
+                       MessageCache::singleton()->replace( $shortTitle, $text );
                }
 
                wfProfileOut( __METHOD__ );
@@ -4051,8 +4049,6 @@ class Article {
         * Clears caches when article is deleted
         */
        public static function onArticleDelete( $title ) {
-               global $wgMessageCache;
-
                # Update existence markers on article/talk tabs...
                if ( $title->isTalkPage() ) {
                        $other = $title->getSubjectPage();
@@ -4071,7 +4067,7 @@ class Article {
 
                # Messages
                if ( $title->getNamespace() == NS_MEDIAWIKI ) {
-                       $wgMessageCache->replace( $title->getDBkey(), false );
+                       MessageCache::singleton()->replace( $title->getDBkey(), false );
                }
 
                # Images
index 8c04326..65df005 100644 (file)
@@ -124,7 +124,7 @@ class EditPage {
         * @private
         */
        function getContent( $def_text = '' ) {
-               global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache;
+               global $wgOut, $wgRequest, $wgParser, $wgContLang;
 
                wfProfileIn( __METHOD__ );
                # Get variables from query string :P
@@ -141,7 +141,7 @@ class EditPage {
                if ( !$this->mTitle->exists() ) {
                        if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
                                # If this is a system message, get the default text.
-                               list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
+                               list( $message, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
                                $text = wfMsgGetKey( $message, false, $lang, false );
                                if( wfEmptyMsg( $message, $text ) )
                                        $text = $this->getPreloadedText( $preload );
@@ -1887,7 +1887,7 @@ HTML
         * @return string
         */
        function getPreviewText() {
-               global $wgOut, $wgUser, $wgParser, $wgMessageCache;
+               global $wgOut, $wgUser, $wgParser;
 
                wfProfileIn( __METHOD__ );
 
@@ -1956,7 +1956,7 @@ HTML
 
                                // Parse mediawiki messages with correct target language
                                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
-                                       list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() );
+                                       list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->mTitle->getText() );
                                        $obj = wfGetLangObj( $lang );
                                        $parserOptions->setTargetLanguage( $obj );
                                }
index 8ad029b..334ad86 100644 (file)
@@ -628,19 +628,14 @@ function wfMsgWeirdKey( $key ) {
  * @return string
  */
 function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) {
-       global $wgMessageCache;
-
        wfRunHooks( 'NormalizeMessageKey', array( &$key, &$useDB, &$langCode, &$transform ) );
 
-       if ( !is_object( $wgMessageCache ) ) {
-               throw new MWException( 'Trying to get message before message cache is initialised' );
-       }
-
-       $message = $wgMessageCache->get( $key, $useDB, $langCode );
+       $cache = MessageCache::singleton();
+       $message = $cache->get( $key, $useDB, $langCode );
        if( $message === false ) {
                $message = '&lt;' . htmlspecialchars( $key ) . '&gt;';
        } elseif ( $transform ) {
-               $message = $wgMessageCache->transform( $message );
+               $message = $cache->transform( $message );
        }
        return $message;
 }
@@ -775,11 +770,8 @@ function wfMsgExt( $key, $options ) {
                        $string = $m[1];
                }
        } elseif ( in_array( 'parsemag', $options, true ) ) {
-               global $wgMessageCache;
-               if ( isset( $wgMessageCache ) ) {
-                       $string = $wgMessageCache->transform( $string,
+               $string = MessageCache::singleton()->transform( $string,
                                !$forContent, $langCodeObj );
-               }
        }
 
        if ( in_array( 'escape', $options, true ) ) {
@@ -2250,8 +2242,7 @@ function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) {
  * @return Boolean True if the message *doesn't* exist.
  */
 function wfEmptyMsg( $key ) {
-       global $wgMessageCache;
-       return $wgMessageCache->get( $key, /*useDB*/true, /*content*/false ) === false;
+       return MessageCache::singleton()->get( $key, /*useDB*/true, /*content*/false ) === false;
 }
 
 /**
index f9dcd00..f81b9bf 100644 (file)
@@ -77,12 +77,6 @@ class LocalisationCache {
         */
        var $recachedLangs = array();
 
-       /**
-        * Data added by extensions using the deprecated $wgMessageCache->addMessages() 
-        * interface.
-        */
-       var $legacyData = array();
-
        /**
         * All item keys
         */
@@ -215,9 +209,6 @@ class LocalisationCache {
         * Get a subitem, for instance a single message for a given language.
         */
        public function getSubitem( $code, $key, $subkey ) {
-               if ( isset( $this->legacyData[$code][$key][$subkey] ) ) {
-                       return $this->legacyData[$code][$key][$subkey];
-               }
                if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) 
                        && !isset( $this->loadedItems[$code][$key] ) ) 
                {
@@ -663,8 +654,6 @@ class LocalisationCache {
                unset( $this->loadedItems[$code] );
                unset( $this->loadedSubitems[$code] );
                unset( $this->initialisedLangs[$code] );
-               // We don't unload legacyData because there's no way to get it back 
-               // again, it's not really a cache
                foreach ( $this->shallowFallbacks as $shallowCode => $fbCode ) {
                        if ( $fbCode === $code ) {
                                $this->unload( $shallowCode );
@@ -681,22 +670,6 @@ class LocalisationCache {
                }
        }
 
-       /**
-        * Add messages to the cache, from an extension that has not yet been 
-        * migrated to $wgExtensionMessages or the LocalisationCacheRecache hook. 
-        * Called by deprecated function $wgMessageCache->addMessages(). 
-        */
-       public function addLegacyMessages( $messages ) {
-               foreach ( $messages as $lang => $langMessages ) {
-                       if ( isset( $this->legacyData[$lang]['messages'] ) ) {
-                               $this->legacyData[$lang]['messages'] = 
-                                       $langMessages + $this->legacyData[$lang]['messages'];
-                       } else {
-                               $this->legacyData[$lang]['messages'] = $langMessages;
-                       }
-               }
-       }
-
        /**
         * Disable the storage backend
         */
index 9ee6eea..14c5bec 100644 (file)
@@ -385,8 +385,7 @@ class Message {
         * @return Wikitext with {{-constructs replaced with their values.
         */
        protected function transformText( $string ) {
-               global $wgMessageCache;
-               return $wgMessageCache->transform( $string, $this->interface, $this->language );
+               return MessageCache::singleton()->transform( $string, $this->interface, $this->language );
        }
 
        /**
@@ -407,17 +406,17 @@ class Message {
         */
        protected function fetchMessage() {
                if ( !isset( $this->message ) ) {
-                       global $wgMessageCache;
+                       $cache = MessageCache::singleton();
                        if ( is_array($this->key) ) {
                                foreach ( $this->key as $key ) {
-                                       $message = $wgMessageCache->get( $key, $this->useDatabase, $this->language );
+                                       $message = $cache->get( $key, $this->useDatabase, $this->language );
                                        if ( $message !== false && $message !== '' ) {
                                                break;
                                        }
                                }
                                $this->message = $message;
                        } else {
-                               $this->message = $wgMessageCache->get( $this->key, $this->useDatabase, $this->language );
+                               $this->message = $cache->get( $this->key, $this->useDatabase, $this->language );
                        }
                }
                return $this->message;
index 3256bf9..73b1b43 100644 (file)
@@ -62,6 +62,34 @@ class MessageCache {
         */
        protected static $mAdaptiveInclusionThreshold = 0.05;
 
+       /**
+        * Singleton instance
+        */
+       private static $instance;
+
+       /**
+        * Get the signleton instance of this class
+        *
+        * @since 1.18
+        * @return MessageCache object
+        */
+       public static function singleton() {
+               if ( is_null( self::$instance ) ) {
+                       global $wgUseDatabaseMessages, $wgMsgCacheExpiry;
+                       self::$instance = new self( wfGetMessageCacheStorage(), $wgUseDatabaseMessages, $wgMsgCacheExpiry );
+               }
+               return self::$instance;
+       }
+
+       /**
+        * Destroy the signleton instance
+        *
+        * @since 1.18
+        */
+       public static function destroyInstance() {
+               self::$instance = null;
+       }
+
        function __construct( $memCached, $useDB, $expiry ) {
                if ( !$memCached ) {
                        $memCached = wfGetCache( CACHE_NONE );
@@ -729,21 +757,6 @@ class MessageCache {
        function disable() { $this->mDisable = true; }
        function enable() { $this->mDisable = false; }
 
-       /** @deprecated */
-       function disableTransform(){
-               wfDeprecated( __METHOD__ );
-       }
-       function enableTransform() {
-               wfDeprecated( __METHOD__ );
-       }
-       function setTransform( $x ) {
-               wfDeprecated( __METHOD__ );
-       }
-       function getTransform() {
-               wfDeprecated( __METHOD__ );
-               return false;
-       }
-
        /**
         * Clear all stored messages. Mainly used after a mass rebuild.
         */
@@ -758,64 +771,6 @@ class MessageCache {
                $this->mLoadedLanguages = array();
        }
 
-       /**
-        * Add a message to the cache
-        * @deprecated Use $wgExtensionMessagesFiles
-        *
-        * @param $key Mixed
-        * @param $value Mixed
-        * @param $lang String: the messages language, English by default
-        */
-       function addMessage( $key, $value, $lang = 'en' ) {
-               wfDeprecated( __METHOD__ );
-               $lc = Language::getLocalisationCache();
-               $lc->addLegacyMessages( array( $lang => array( $key => $value ) ) );
-       }
-
-       /**
-        * Add an associative array of message to the cache
-        * @deprecated Use $wgExtensionMessagesFiles
-        *
-        * @param $messages Array: an associative array of key => values to be added
-        * @param $lang String: the messages language, English by default
-        */
-       function addMessages( $messages, $lang = 'en' ) {
-               wfDeprecated( __METHOD__ );
-               $lc = Language::getLocalisationCache();
-               $lc->addLegacyMessages( array( $lang => $messages ) );
-       }
-
-       /**
-        * Add a 2-D array of messages by lang. Useful for extensions.
-        * @deprecated Use $wgExtensionMessagesFiles
-        *
-        * @param $messages Array: the array to be added
-        */
-       function addMessagesByLang( $messages ) {
-               wfDeprecated( __METHOD__ );
-               $lc = Language::getLocalisationCache();
-               $lc->addLegacyMessages( $messages );
-       }
-
-       /**
-        * Set a hook for addMessagesByLang()
-        */
-       function setExtensionMessagesHook( $callback ) {
-               $this->mAddMessagesHook = $callback;
-       }
-
-       /**
-        * @deprecated
-        */
-       function loadAllMessages( $lang = false ) {
-       }
-
-       /**
-        * @deprecated
-        */
-       function loadMessagesFile( $filename, $langcode = false ) {
-       }
-
        public function figureMessage( $key ) {
                global $wgLanguageCode;
                $pieces = explode( '/', $key );
@@ -832,8 +787,8 @@ class MessageCache {
        }
 
        public static function logMessages() {
-               global $wgMessageCache, $wgAdaptiveMessageCache;
-               if ( !$wgAdaptiveMessageCache || !$wgMessageCache instanceof MessageCache ) {
+               global $wgAdaptiveMessageCache;
+               if ( !$wgAdaptiveMessageCache || !self::$instance instanceof MessageCache ) {
                        return;
                }
 
@@ -852,7 +807,7 @@ class MessageCache {
                $index = substr( wfTimestampNow(), 0, 8 );
                if ( !isset( $data[$index] ) ) $data[$index] = array();
 
-               foreach ( $wgMessageCache->mRequestedMessages as $message => $_ ) {
+               foreach ( self::$instance->mRequestedMessages as $message => $_ ) {
                        if ( !isset( $data[$index][$message] ) ) $data[$index][$message] = 0;
                        $data[$index][$message]++;
                }
index e51efee..f03f625 100644 (file)
@@ -387,9 +387,6 @@ $wgLang = new StubUserLang;
 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
 
-$wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
-       array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) );
-
 if ( !is_object( $wgAuth ) ) {
        $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
        wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
index 3934272..421be43 100644 (file)
@@ -3193,20 +3193,19 @@ class Title {
                        $u->doUpdate();
                }
                # Update message cache for interface messages
-               global $wgMessageCache;
                if ( $this->getNamespace() == NS_MEDIAWIKI ) {
                        # @bug 17860: old article can be deleted, if this the case,
                        # delete it from message cache
                        if ( $this->getArticleID() === 0 ) {
-                               $wgMessageCache->replace( $this->getDBkey(), false );
+                               MessageCache::singleton()->replace( $this->getDBkey(), false );
                        } else {
                                $oldarticle = new Article( $this );
-                               $wgMessageCache->replace( $this->getDBkey(), $oldarticle->getContent() );
+                               MessageCache::singleton()->replace( $this->getDBkey(), $oldarticle->getContent() );
                        }
                }
                if ( $nt->getNamespace() == NS_MEDIAWIKI ) {
                        $newarticle = new Article( $nt );
-                       $wgMessageCache->replace( $nt->getDBkey(), $newarticle->getContent() );
+                       MessageCache::singleton()->replace( $nt->getDBkey(), $newarticle->getContent() );
                }
 
                global $wgUser;
index f5233de..3e0e70a 100644 (file)
@@ -2897,7 +2897,7 @@ class DBConnectionError extends DBError {
        }
 
        function getHTML() {
-               global $wgLang, $wgMessageCache, $wgUseFileCache, $wgShowDBErrorBacktrace;
+               global $wgLang, $wgUseFileCache, $wgShowDBErrorBacktrace;
 
                $sorry = 'Sorry! This site is experiencing technical difficulties.';
                $again = 'Try waiting a few minutes and reloading.';
@@ -2910,9 +2910,7 @@ class DBConnectionError extends DBError {
                }
 
                # No database access
-               if ( is_object( $wgMessageCache ) ) {
-                       $wgMessageCache->disable();
-               }
+               MessageCache::singleton()->disable();
 
                if ( trim( $this->error ) == '' ) {
                        $this->error = $this->db->getProperty( 'mServer' );
index 6b999b5..b76c798 100644 (file)
@@ -88,7 +88,7 @@ class CoreParserFunctions {
                        $args = array_slice( func_get_args(), 2 );
                        $message = wfMsgGetKey( $part1, true, $parser->getOptions()->getUserLang(), false );
                        $message = wfMsgReplaceArgs( $message, $args );
-                       $message = $parser->replaceVariables( $message ); // like $wgMessageCache->transform()
+                       $message = $parser->replaceVariables( $message ); // like MessageCache::transform()
                        return $message;
                } else {
                        return array( 'found' => false );
index 5b46b57..5528c15 100644 (file)
@@ -842,13 +842,8 @@ class LanguageConverter {
         *
         */
        function parseCachedTable( $code, $subpage = '', $recursive = true ) {
-               global $wgMessageCache;
                static $parsed = array();
 
-               if ( !is_object( $wgMessageCache ) ) {
-                       return array();
-               }
-
                $key = 'Conversiontable/' . $code;
                if ( $subpage ) {
                        $key .= '/' . $subpage;
@@ -858,7 +853,7 @@ class LanguageConverter {
                }
 
                if ( strpos( $code, '/' ) === false ) {
-                       $txt = $wgMessageCache->get( 'Conversiontable', true, $code );
+                       $txt = MessageCache::singleton()->get( 'Conversiontable', true, $code );
                        if ( $txt === false ) {
                                # FIXME: this method doesn't seem to be expecting
                                # this possible outcome...
index cb1086a..aeaf593 100644 (file)
@@ -134,9 +134,8 @@ class ParserTest {
        static function setUp() {
                global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList,
                        $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
-                       $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc,
                        $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
-                       $wgThumbnailScriptPath, $wgScriptPath,
+                       $parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
                        $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
 
                $wgScript = '/index.php';
@@ -172,9 +171,6 @@ class ParserTest {
                $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
                $wgRequest = new WebRequest;
 
-               $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
-                                                                                 array( $messageMemc, $wgUseDatabaseMessages,
-                                                                                                $wgMsgCacheExpiry ) );
                if ( $wgStyleDirectory === false ) {
                        $wgStyleDirectory   = "$IP/skins";
                }
@@ -821,9 +817,8 @@ class ParserTest {
                # Reinitialise the LocalisationCache to match the database state
                Language::getLocalisationCache()->unloadAll();
 
-               # Make a new message cache
-               global $wgMessageCache, $wgMemc;
-               $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
+               # Clear the message cache
+               MessageCache::singleton()->clear();
 
                $this->uploadDir = $this->setupUploadDir();
                $user = User::createNew( 'WikiSysop' );
index 46d2534..f96ab00 100644 (file)
@@ -28,14 +28,12 @@ dependencies.
 EOF;
 }
 
-global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
-global $wgMessageCache, $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgMemc;
+global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgUseDatabaseMessages, $wgMemc;
 $wgMainCacheType = CACHE_NONE;
 $wgMessageCacheType = CACHE_NONE;
 $wgParserCacheType = CACHE_NONE;
 $wgUseDatabaseMessages = false; # Set for future resets
 $wgMemc = new FakeMemCachedClient;
 
-# The message cache was already created in Setup.php
-$wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
-       array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) );
+/** @todo Check if this is really needed */
+MessageCache::destroyInstance();
index 67dc009..2e13d22 100644 (file)
@@ -3,12 +3,12 @@
 class MessageTest extends MediaWikiTestCase {
 
        function setUp() {
-               global $wgLanguageCode, $wgLang, $wgContLang, $wgMessageCache;
+               global $wgLanguageCode, $wgLang, $wgContLang;
 
                $wgLanguageCode = 'en'; # For mainpage to be 'Main Page'
                //Note that a Stub Object is not enough for this test
                $wgContLang = $wgLang = Language::factory( $wgLanguageCode );
-               $wgMessageCache = new MessageCache( false, false, 3600 );
+               MessageCache::singleton()->disable();
        }
 
        function testExists() {
index 315ecd2..befeee8 100644 (file)
@@ -13,12 +13,11 @@ class TitlePermissionTest extends MediaWikiTestCase {
        protected $altUserName;
 
        function setUp() {
-               global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang, $wgMessageCache;
+               global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang;
 
                if(!$wgMemc) {
                        $wgMemc = new FakeMemCachedClient;
                }
-               $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
                $wgContLang = $wgLang = Language::factory( 'en' );
 
                $this->userName = "Useruser";
index a13e4d6..5adbfe6 100644 (file)
@@ -24,7 +24,7 @@ class NewParserTest extends MediaWikiTestCase {
        //PHPUnit + MediaWikiTestCase functions
 
        function setUp() {
-               global $wgContLang, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgNamespaceProtection, $wgNamespaceAliases, $IP, $messageMemc;
+               global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases, $IP;
                $wgContLang = Language::factory( 'en' );
                
                //Setup CLI arguments
@@ -58,7 +58,7 @@ class NewParserTest extends MediaWikiTestCase {
                $tmpGlobals['wgEnableParserCache'] = false;
                $tmpGlobals['wgDeferredUpdateList'] = array();
                $tmpGlobals['wgMemc'] = &wfGetMainCache();
-               $messageMemc = &wfGetMessageCacheStorage();
+               $tmpGlobals['messageMemc'] = &wfGetMessageCacheStorage();
                $tmpGlobals['parserMemc'] = &wfGetParserCacheStorage();
 
                // $tmpGlobals['wgContLang'] = new StubContLang;
@@ -68,9 +68,6 @@ class NewParserTest extends MediaWikiTestCase {
                $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) );
                $tmpGlobals['wgRequest'] = new WebRequest;
 
-               $tmpGlobals['wgMessageCache'] = new StubObject( 'wgMessageCache', 'MessageCache',
-                                                                                 array( $messageMemc, $wgUseDatabaseMessages,
-                                                                                                $wgMsgCacheExpiry ) );
                if ( $GLOBALS['wgStyleDirectory'] === false ) {
                        $tmpGlobals['wgStyleDirectory'] = "$IP/skins";
                }
@@ -150,9 +147,8 @@ class NewParserTest extends MediaWikiTestCase {
                # Reinitialise the LocalisationCache to match the database state
                Language::getLocalisationCache()->unloadAll();
 
-               # Make a new message cache
-               global $wgMessageCache, $wgMemc;
-               $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
+               # Clear the message cache
+               MessageCache::singleton()->clear();
 
                $this->uploadDir = $this->setupUploadDir();
                
index 3f5b1fe..cfa7cf5 100644 (file)
@@ -16,9 +16,8 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
        function setUp() {
                global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList,
                                  $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
-                                 $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc,
                                  $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
-                                 $wgThumbnailScriptPath, $wgScriptPath,
+                                 $parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
                                  $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
 
                $wgScript = '/index.php';
@@ -54,9 +53,6 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
                $wgRequest = new WebRequest;
 
-               $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
-                                                                                 array( $messageMemc, $wgUseDatabaseMessages,
-                                                                                                $wgMsgCacheExpiry ) );
                if ( $wgStyleDirectory === false ) {
                        $wgStyleDirectory   = "$IP/skins";
                }