From 51c6afc751e5e038952ef1fc325676489bbb08fd Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 26 Jan 2011 15:42:04 +0000 Subject: [PATCH] * Replaced $wgMessageCache by MessageCache::singleton(); since we only use one instance of this class (as for ParserCache, LinkCache) * 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 --- docs/globals.txt | 3 - includes/Article.php | 16 +-- includes/EditPage.php | 8 +- includes/GlobalFunctions.php | 19 +--- includes/LocalisationCache.php | 27 ----- includes/Message.php | 9 +- includes/MessageCache.php | 107 +++++------------- includes/Setup.php | 3 - includes/Title.php | 7 +- includes/db/Database.php | 6 +- includes/parser/CoreParserFunctions.php | 2 +- languages/LanguageConverter.php | 7 +- tests/parser/parserTest.inc | 11 +- tests/phpunit/bootstrap.php | 8 +- tests/phpunit/includes/MessageTest.php | 4 +- .../phpunit/includes/TitlePermissionTest.php | 3 +- .../phpunit/includes/parser/NewParserTest.php | 12 +- .../phpunit/suites/UploadFromUrlTestSuite.php | 6 +- 18 files changed, 71 insertions(+), 187 deletions(-) diff --git a/docs/globals.txt b/docs/globals.txt index 46486dd824..bb3b294656 100644 --- a/docs/globals.txt +++ b/docs/globals.txt @@ -68,6 +68,3 @@ $wgRequest $wgMemc, $messageMemc, $parserMemc Object caches - -$wgMessageCache - Message cache, to manage interface messages diff --git a/includes/Article.php b/includes/Article.php index 44bd713078..726797e658 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 diff --git a/includes/EditPage.php b/includes/EditPage.php index 8c04326064..65df005ab7 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 ); } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 8ad029ba6f..334ad86b93 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 = '<' . htmlspecialchars( $key ) . '>'; } 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; } /** diff --git a/includes/LocalisationCache.php b/includes/LocalisationCache.php index f9dcd0042f..f81b9bf5af 100644 --- a/includes/LocalisationCache.php +++ b/includes/LocalisationCache.php @@ -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 */ diff --git a/includes/Message.php b/includes/Message.php index 9ee6eea51f..14c5bec9c9 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -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; diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 3256bf9867..73b1b43ac5 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -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]++; } diff --git a/includes/Setup.php b/includes/Setup.php index e51efee49a..f03f625c82 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ) ); diff --git a/includes/Title.php b/includes/Title.php index 3934272452..421be43fbf 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; diff --git a/includes/db/Database.php b/includes/db/Database.php index f5233de9d9..3e0e70a51d 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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' ); diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 6b999b5e05..b76c7985d0 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -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 ); diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 5b46b57bca..5528c1555d 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -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... diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index cb1086afe1..aeaf593cd6 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -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' ); diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 46d2534520..f96ab003cc 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -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(); diff --git a/tests/phpunit/includes/MessageTest.php b/tests/phpunit/includes/MessageTest.php index 67dc00906e..2e13d229b4 100644 --- a/tests/phpunit/includes/MessageTest.php +++ b/tests/phpunit/includes/MessageTest.php @@ -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() { diff --git a/tests/phpunit/includes/TitlePermissionTest.php b/tests/phpunit/includes/TitlePermissionTest.php index 315ecd26db..befeee8d24 100644 --- a/tests/phpunit/includes/TitlePermissionTest.php +++ b/tests/phpunit/includes/TitlePermissionTest.php @@ -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"; diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index a13e4d6684..5adbfe6f68 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -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(); diff --git a/tests/phpunit/suites/UploadFromUrlTestSuite.php b/tests/phpunit/suites/UploadFromUrlTestSuite.php index 3f5b1fe53e..cfa7cf5620 100644 --- a/tests/phpunit/suites/UploadFromUrlTestSuite.php +++ b/tests/phpunit/suites/UploadFromUrlTestSuite.php @@ -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"; } -- 2.20.1