Index: trunk/phase3/docs/globals.txt |
— | — | @@ -68,6 +68,3 @@ |
69 | 69 | |
70 | 70 | $wgMemc, $messageMemc, $parserMemc |
71 | 71 | Object caches |
72 | | - |
73 | | -$wgMessageCache |
74 | | - Message cache, to manage interface messages |
Index: trunk/phase3/tests/phpunit/bootstrap.php |
— | — | @@ -28,14 +28,12 @@ |
29 | 29 | EOF; |
30 | 30 | } |
31 | 31 | |
32 | | -global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType; |
33 | | -global $wgMessageCache, $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgMemc; |
| 32 | +global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgUseDatabaseMessages, $wgMemc; |
34 | 33 | $wgMainCacheType = CACHE_NONE; |
35 | 34 | $wgMessageCacheType = CACHE_NONE; |
36 | 35 | $wgParserCacheType = CACHE_NONE; |
37 | 36 | $wgUseDatabaseMessages = false; # Set for future resets |
38 | 37 | $wgMemc = new FakeMemCachedClient; |
39 | 38 | |
40 | | -# The message cache was already created in Setup.php |
41 | | -$wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', |
42 | | - array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) ); |
| 39 | +/** @todo Check if this is really needed */ |
| 40 | +MessageCache::destroyInstance(); |
Index: trunk/phase3/tests/phpunit/includes/MessageTest.php |
— | — | @@ -3,12 +3,12 @@ |
4 | 4 | class MessageTest extends MediaWikiTestCase { |
5 | 5 | |
6 | 6 | function setUp() { |
7 | | - global $wgLanguageCode, $wgLang, $wgContLang, $wgMessageCache; |
| 7 | + global $wgLanguageCode, $wgLang, $wgContLang; |
8 | 8 | |
9 | 9 | $wgLanguageCode = 'en'; # For mainpage to be 'Main Page' |
10 | 10 | //Note that a Stub Object is not enough for this test |
11 | 11 | $wgContLang = $wgLang = Language::factory( $wgLanguageCode ); |
12 | | - $wgMessageCache = new MessageCache( false, false, 3600 ); |
| 12 | + MessageCache::singleton()->disable(); |
13 | 13 | } |
14 | 14 | |
15 | 15 | function testExists() { |
Index: trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php |
— | — | @@ -13,12 +13,11 @@ |
14 | 14 | protected $altUserName; |
15 | 15 | |
16 | 16 | function setUp() { |
17 | | - global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang, $wgMessageCache; |
| 17 | + global $wgLocaltimezone, $wgLocalTZoffset, $wgMemc, $wgContLang, $wgLang; |
18 | 18 | |
19 | 19 | if(!$wgMemc) { |
20 | 20 | $wgMemc = new FakeMemCachedClient; |
21 | 21 | } |
22 | | - $wgMessageCache = new MessageCache( $wgMemc, true, 3600 ); |
23 | 22 | $wgContLang = $wgLang = Language::factory( 'en' ); |
24 | 23 | |
25 | 24 | $this->userName = "Useruser"; |
Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | //PHPUnit + MediaWikiTestCase functions |
26 | 26 | |
27 | 27 | function setUp() { |
28 | | - global $wgContLang, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgNamespaceProtection, $wgNamespaceAliases, $IP, $messageMemc; |
| 28 | + global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases, $IP; |
29 | 29 | $wgContLang = Language::factory( 'en' ); |
30 | 30 | |
31 | 31 | //Setup CLI arguments |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | $tmpGlobals['wgEnableParserCache'] = false; |
60 | 60 | $tmpGlobals['wgDeferredUpdateList'] = array(); |
61 | 61 | $tmpGlobals['wgMemc'] = &wfGetMainCache(); |
62 | | - $messageMemc = &wfGetMessageCacheStorage(); |
| 62 | + $tmpGlobals['messageMemc'] = &wfGetMessageCacheStorage(); |
63 | 63 | $tmpGlobals['parserMemc'] = &wfGetParserCacheStorage(); |
64 | 64 | |
65 | 65 | // $tmpGlobals['wgContLang'] = new StubContLang; |
— | — | @@ -68,9 +68,6 @@ |
69 | 69 | $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) ); |
70 | 70 | $tmpGlobals['wgRequest'] = new WebRequest; |
71 | 71 | |
72 | | - $tmpGlobals['wgMessageCache'] = new StubObject( 'wgMessageCache', 'MessageCache', |
73 | | - array( $messageMemc, $wgUseDatabaseMessages, |
74 | | - $wgMsgCacheExpiry ) ); |
75 | 72 | if ( $GLOBALS['wgStyleDirectory'] === false ) { |
76 | 73 | $tmpGlobals['wgStyleDirectory'] = "$IP/skins"; |
77 | 74 | } |
— | — | @@ -150,9 +147,8 @@ |
151 | 148 | # Reinitialise the LocalisationCache to match the database state |
152 | 149 | Language::getLocalisationCache()->unloadAll(); |
153 | 150 | |
154 | | - # Make a new message cache |
155 | | - global $wgMessageCache, $wgMemc; |
156 | | - $wgMessageCache = new MessageCache( $wgMemc, true, 3600 ); |
| 151 | + # Clear the message cache |
| 152 | + MessageCache::singleton()->clear(); |
157 | 153 | |
158 | 154 | $this->uploadDir = $this->setupUploadDir(); |
159 | 155 | |
Index: trunk/phase3/tests/phpunit/suites/UploadFromUrlTestSuite.php |
— | — | @@ -16,9 +16,8 @@ |
17 | 17 | function setUp() { |
18 | 18 | global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, |
19 | 19 | $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, |
20 | | - $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc, |
21 | 20 | $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, |
22 | | - $wgThumbnailScriptPath, $wgScriptPath, |
| 21 | + $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, |
23 | 22 | $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath; |
24 | 23 | |
25 | 24 | $wgScript = '/index.php'; |
— | — | @@ -54,9 +53,6 @@ |
55 | 54 | $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); |
56 | 55 | $wgRequest = new WebRequest; |
57 | 56 | |
58 | | - $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', |
59 | | - array( $messageMemc, $wgUseDatabaseMessages, |
60 | | - $wgMsgCacheExpiry ) ); |
61 | 57 | if ( $wgStyleDirectory === false ) { |
62 | 58 | $wgStyleDirectory = "$IP/skins"; |
63 | 59 | } |
Index: trunk/phase3/tests/parser/parserTest.inc |
— | — | @@ -134,9 +134,8 @@ |
135 | 135 | static function setUp() { |
136 | 136 | global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, |
137 | 137 | $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, |
138 | | - $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc, |
139 | 138 | $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, |
140 | | - $wgThumbnailScriptPath, $wgScriptPath, |
| 139 | + $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, |
141 | 140 | $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath; |
142 | 141 | |
143 | 142 | $wgScript = '/index.php'; |
— | — | @@ -172,9 +171,6 @@ |
173 | 172 | $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); |
174 | 173 | $wgRequest = new WebRequest; |
175 | 174 | |
176 | | - $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', |
177 | | - array( $messageMemc, $wgUseDatabaseMessages, |
178 | | - $wgMsgCacheExpiry ) ); |
179 | 175 | if ( $wgStyleDirectory === false ) { |
180 | 176 | $wgStyleDirectory = "$IP/skins"; |
181 | 177 | } |
— | — | @@ -821,9 +817,8 @@ |
822 | 818 | # Reinitialise the LocalisationCache to match the database state |
823 | 819 | Language::getLocalisationCache()->unloadAll(); |
824 | 820 | |
825 | | - # Make a new message cache |
826 | | - global $wgMessageCache, $wgMemc; |
827 | | - $wgMessageCache = new MessageCache( $wgMemc, true, 3600 ); |
| 821 | + # Clear the message cache |
| 822 | + MessageCache::singleton()->clear(); |
828 | 823 | |
829 | 824 | $this->uploadDir = $this->setupUploadDir(); |
830 | 825 | $user = User::createNew( 'WikiSysop' ); |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | * @return Return the text of this revision |
251 | 251 | */ |
252 | 252 | public function getContent() { |
253 | | - global $wgUser, $wgContLang, $wgMessageCache; |
| 253 | + global $wgUser, $wgContLang; |
254 | 254 | |
255 | 255 | wfProfileIn( __METHOD__ ); |
256 | 256 | |
— | — | @@ -258,7 +258,7 @@ |
259 | 259 | # and return the message value for x. |
260 | 260 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
261 | 261 | # If this is a system message, get the default text. |
262 | | - list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); |
| 262 | + list( $message, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); |
263 | 263 | $text = wfMsgGetKey( $message, false, $lang, false ); |
264 | 264 | |
265 | 265 | if ( wfEmptyMsg( $message, $text ) ) |
— | — | @@ -1712,15 +1712,13 @@ |
1713 | 1713 | } |
1714 | 1714 | |
1715 | 1715 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1716 | | - global $wgMessageCache; |
1717 | | - |
1718 | 1716 | if ( $this->getID() == 0 ) { |
1719 | 1717 | $text = false; |
1720 | 1718 | } else { |
1721 | 1719 | $text = $this->getRawText(); |
1722 | 1720 | } |
1723 | 1721 | |
1724 | | - $wgMessageCache->replace( $this->mTitle->getDBkey(), $text ); |
| 1722 | + MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text ); |
1725 | 1723 | } |
1726 | 1724 | } |
1727 | 1725 | |
— | — | @@ -3632,7 +3630,7 @@ |
3633 | 3631 | * @param $user User object: User doing the edit |
3634 | 3632 | */ |
3635 | 3633 | public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true, User $user = null ) { |
3636 | | - global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgEnableParserCache; |
| 3634 | + global $wgDeferredUpdateList, $wgUser, $wgEnableParserCache; |
3637 | 3635 | |
3638 | 3636 | wfProfileIn( __METHOD__ ); |
3639 | 3637 | |
— | — | @@ -3710,7 +3708,7 @@ |
3711 | 3709 | } |
3712 | 3710 | |
3713 | 3711 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
3714 | | - $wgMessageCache->replace( $shortTitle, $text ); |
| 3712 | + MessageCache::singleton()->replace( $shortTitle, $text ); |
3715 | 3713 | } |
3716 | 3714 | |
3717 | 3715 | wfProfileOut( __METHOD__ ); |
— | — | @@ -4051,8 +4049,6 @@ |
4052 | 4050 | * Clears caches when article is deleted |
4053 | 4051 | */ |
4054 | 4052 | public static function onArticleDelete( $title ) { |
4055 | | - global $wgMessageCache; |
4056 | | - |
4057 | 4053 | # Update existence markers on article/talk tabs... |
4058 | 4054 | if ( $title->isTalkPage() ) { |
4059 | 4055 | $other = $title->getSubjectPage(); |
— | — | @@ -4071,7 +4067,7 @@ |
4072 | 4068 | |
4073 | 4069 | # Messages |
4074 | 4070 | if ( $title->getNamespace() == NS_MEDIAWIKI ) { |
4075 | | - $wgMessageCache->replace( $title->getDBkey(), false ); |
| 4071 | + MessageCache::singleton()->replace( $title->getDBkey(), false ); |
4076 | 4072 | } |
4077 | 4073 | |
4078 | 4074 | # Images |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -628,19 +628,14 @@ |
629 | 629 | * @return string |
630 | 630 | */ |
631 | 631 | function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) { |
632 | | - global $wgMessageCache; |
633 | | - |
634 | 632 | wfRunHooks( 'NormalizeMessageKey', array( &$key, &$useDB, &$langCode, &$transform ) ); |
635 | 633 | |
636 | | - if ( !is_object( $wgMessageCache ) ) { |
637 | | - throw new MWException( 'Trying to get message before message cache is initialised' ); |
638 | | - } |
639 | | - |
640 | | - $message = $wgMessageCache->get( $key, $useDB, $langCode ); |
| 634 | + $cache = MessageCache::singleton(); |
| 635 | + $message = $cache->get( $key, $useDB, $langCode ); |
641 | 636 | if( $message === false ) { |
642 | 637 | $message = '<' . htmlspecialchars( $key ) . '>'; |
643 | 638 | } elseif ( $transform ) { |
644 | | - $message = $wgMessageCache->transform( $message ); |
| 639 | + $message = $cache->transform( $message ); |
645 | 640 | } |
646 | 641 | return $message; |
647 | 642 | } |
— | — | @@ -775,11 +770,8 @@ |
776 | 771 | $string = $m[1]; |
777 | 772 | } |
778 | 773 | } elseif ( in_array( 'parsemag', $options, true ) ) { |
779 | | - global $wgMessageCache; |
780 | | - if ( isset( $wgMessageCache ) ) { |
781 | | - $string = $wgMessageCache->transform( $string, |
| 774 | + $string = MessageCache::singleton()->transform( $string, |
782 | 775 | !$forContent, $langCodeObj ); |
783 | | - } |
784 | 776 | } |
785 | 777 | |
786 | 778 | if ( in_array( 'escape', $options, true ) ) { |
— | — | @@ -2250,8 +2242,7 @@ |
2251 | 2243 | * @return Boolean True if the message *doesn't* exist. |
2252 | 2244 | */ |
2253 | 2245 | function wfEmptyMsg( $key ) { |
2254 | | - global $wgMessageCache; |
2255 | | - return $wgMessageCache->get( $key, /*useDB*/true, /*content*/false ) === false; |
| 2246 | + return MessageCache::singleton()->get( $key, /*useDB*/true, /*content*/false ) === false; |
2256 | 2247 | } |
2257 | 2248 | |
2258 | 2249 | /** |
Index: trunk/phase3/includes/LocalisationCache.php |
— | — | @@ -78,12 +78,6 @@ |
79 | 79 | var $recachedLangs = array(); |
80 | 80 | |
81 | 81 | /** |
82 | | - * Data added by extensions using the deprecated $wgMessageCache->addMessages() |
83 | | - * interface. |
84 | | - */ |
85 | | - var $legacyData = array(); |
86 | | - |
87 | | - /** |
88 | 82 | * All item keys |
89 | 83 | */ |
90 | 84 | static public $allKeys = array( |
— | — | @@ -215,9 +209,6 @@ |
216 | 210 | * Get a subitem, for instance a single message for a given language. |
217 | 211 | */ |
218 | 212 | public function getSubitem( $code, $key, $subkey ) { |
219 | | - if ( isset( $this->legacyData[$code][$key][$subkey] ) ) { |
220 | | - return $this->legacyData[$code][$key][$subkey]; |
221 | | - } |
222 | 213 | if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) |
223 | 214 | && !isset( $this->loadedItems[$code][$key] ) ) |
224 | 215 | { |
— | — | @@ -663,8 +654,6 @@ |
664 | 655 | unset( $this->loadedItems[$code] ); |
665 | 656 | unset( $this->loadedSubitems[$code] ); |
666 | 657 | unset( $this->initialisedLangs[$code] ); |
667 | | - // We don't unload legacyData because there's no way to get it back |
668 | | - // again, it's not really a cache |
669 | 658 | foreach ( $this->shallowFallbacks as $shallowCode => $fbCode ) { |
670 | 659 | if ( $fbCode === $code ) { |
671 | 660 | $this->unload( $shallowCode ); |
— | — | @@ -682,22 +671,6 @@ |
683 | 672 | } |
684 | 673 | |
685 | 674 | /** |
686 | | - * Add messages to the cache, from an extension that has not yet been |
687 | | - * migrated to $wgExtensionMessages or the LocalisationCacheRecache hook. |
688 | | - * Called by deprecated function $wgMessageCache->addMessages(). |
689 | | - */ |
690 | | - public function addLegacyMessages( $messages ) { |
691 | | - foreach ( $messages as $lang => $langMessages ) { |
692 | | - if ( isset( $this->legacyData[$lang]['messages'] ) ) { |
693 | | - $this->legacyData[$lang]['messages'] = |
694 | | - $langMessages + $this->legacyData[$lang]['messages']; |
695 | | - } else { |
696 | | - $this->legacyData[$lang]['messages'] = $langMessages; |
697 | | - } |
698 | | - } |
699 | | - } |
700 | | - |
701 | | - /** |
702 | 675 | * Disable the storage backend |
703 | 676 | */ |
704 | 677 | public function disableBackend() { |
Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | $args = array_slice( func_get_args(), 2 ); |
90 | 90 | $message = wfMsgGetKey( $part1, true, $parser->getOptions()->getUserLang(), false ); |
91 | 91 | $message = wfMsgReplaceArgs( $message, $args ); |
92 | | - $message = $parser->replaceVariables( $message ); // like $wgMessageCache->transform() |
| 92 | + $message = $parser->replaceVariables( $message ); // like MessageCache::transform() |
93 | 93 | return $message; |
94 | 94 | } else { |
95 | 95 | return array( 'found' => false ); |
Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -62,6 +62,34 @@ |
63 | 63 | */ |
64 | 64 | protected static $mAdaptiveInclusionThreshold = 0.05; |
65 | 65 | |
| 66 | + /** |
| 67 | + * Singleton instance |
| 68 | + */ |
| 69 | + private static $instance; |
| 70 | + |
| 71 | + /** |
| 72 | + * Get the signleton instance of this class |
| 73 | + * |
| 74 | + * @since 1.18 |
| 75 | + * @return MessageCache object |
| 76 | + */ |
| 77 | + public static function singleton() { |
| 78 | + if ( is_null( self::$instance ) ) { |
| 79 | + global $wgUseDatabaseMessages, $wgMsgCacheExpiry; |
| 80 | + self::$instance = new self( wfGetMessageCacheStorage(), $wgUseDatabaseMessages, $wgMsgCacheExpiry ); |
| 81 | + } |
| 82 | + return self::$instance; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Destroy the signleton instance |
| 87 | + * |
| 88 | + * @since 1.18 |
| 89 | + */ |
| 90 | + public static function destroyInstance() { |
| 91 | + self::$instance = null; |
| 92 | + } |
| 93 | + |
66 | 94 | function __construct( $memCached, $useDB, $expiry ) { |
67 | 95 | if ( !$memCached ) { |
68 | 96 | $memCached = wfGetCache( CACHE_NONE ); |
— | — | @@ -729,21 +757,6 @@ |
730 | 758 | function disable() { $this->mDisable = true; } |
731 | 759 | function enable() { $this->mDisable = false; } |
732 | 760 | |
733 | | - /** @deprecated */ |
734 | | - function disableTransform(){ |
735 | | - wfDeprecated( __METHOD__ ); |
736 | | - } |
737 | | - function enableTransform() { |
738 | | - wfDeprecated( __METHOD__ ); |
739 | | - } |
740 | | - function setTransform( $x ) { |
741 | | - wfDeprecated( __METHOD__ ); |
742 | | - } |
743 | | - function getTransform() { |
744 | | - wfDeprecated( __METHOD__ ); |
745 | | - return false; |
746 | | - } |
747 | | - |
748 | 761 | /** |
749 | 762 | * Clear all stored messages. Mainly used after a mass rebuild. |
750 | 763 | */ |
— | — | @@ -758,64 +771,6 @@ |
759 | 772 | $this->mLoadedLanguages = array(); |
760 | 773 | } |
761 | 774 | |
762 | | - /** |
763 | | - * Add a message to the cache |
764 | | - * @deprecated Use $wgExtensionMessagesFiles |
765 | | - * |
766 | | - * @param $key Mixed |
767 | | - * @param $value Mixed |
768 | | - * @param $lang String: the messages language, English by default |
769 | | - */ |
770 | | - function addMessage( $key, $value, $lang = 'en' ) { |
771 | | - wfDeprecated( __METHOD__ ); |
772 | | - $lc = Language::getLocalisationCache(); |
773 | | - $lc->addLegacyMessages( array( $lang => array( $key => $value ) ) ); |
774 | | - } |
775 | | - |
776 | | - /** |
777 | | - * Add an associative array of message to the cache |
778 | | - * @deprecated Use $wgExtensionMessagesFiles |
779 | | - * |
780 | | - * @param $messages Array: an associative array of key => values to be added |
781 | | - * @param $lang String: the messages language, English by default |
782 | | - */ |
783 | | - function addMessages( $messages, $lang = 'en' ) { |
784 | | - wfDeprecated( __METHOD__ ); |
785 | | - $lc = Language::getLocalisationCache(); |
786 | | - $lc->addLegacyMessages( array( $lang => $messages ) ); |
787 | | - } |
788 | | - |
789 | | - /** |
790 | | - * Add a 2-D array of messages by lang. Useful for extensions. |
791 | | - * @deprecated Use $wgExtensionMessagesFiles |
792 | | - * |
793 | | - * @param $messages Array: the array to be added |
794 | | - */ |
795 | | - function addMessagesByLang( $messages ) { |
796 | | - wfDeprecated( __METHOD__ ); |
797 | | - $lc = Language::getLocalisationCache(); |
798 | | - $lc->addLegacyMessages( $messages ); |
799 | | - } |
800 | | - |
801 | | - /** |
802 | | - * Set a hook for addMessagesByLang() |
803 | | - */ |
804 | | - function setExtensionMessagesHook( $callback ) { |
805 | | - $this->mAddMessagesHook = $callback; |
806 | | - } |
807 | | - |
808 | | - /** |
809 | | - * @deprecated |
810 | | - */ |
811 | | - function loadAllMessages( $lang = false ) { |
812 | | - } |
813 | | - |
814 | | - /** |
815 | | - * @deprecated |
816 | | - */ |
817 | | - function loadMessagesFile( $filename, $langcode = false ) { |
818 | | - } |
819 | | - |
820 | 775 | public function figureMessage( $key ) { |
821 | 776 | global $wgLanguageCode; |
822 | 777 | $pieces = explode( '/', $key ); |
— | — | @@ -832,8 +787,8 @@ |
833 | 788 | } |
834 | 789 | |
835 | 790 | public static function logMessages() { |
836 | | - global $wgMessageCache, $wgAdaptiveMessageCache; |
837 | | - if ( !$wgAdaptiveMessageCache || !$wgMessageCache instanceof MessageCache ) { |
| 791 | + global $wgAdaptiveMessageCache; |
| 792 | + if ( !$wgAdaptiveMessageCache || !self::$instance instanceof MessageCache ) { |
838 | 793 | return; |
839 | 794 | } |
840 | 795 | |
— | — | @@ -852,7 +807,7 @@ |
853 | 808 | $index = substr( wfTimestampNow(), 0, 8 ); |
854 | 809 | if ( !isset( $data[$index] ) ) $data[$index] = array(); |
855 | 810 | |
856 | | - foreach ( $wgMessageCache->mRequestedMessages as $message => $_ ) { |
| 811 | + foreach ( self::$instance->mRequestedMessages as $message => $_ ) { |
857 | 812 | if ( !isset( $data[$index][$message] ) ) $data[$index][$message] = 0; |
858 | 813 | $data[$index][$message]++; |
859 | 814 | } |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2897,7 +2897,7 @@ |
2898 | 2898 | } |
2899 | 2899 | |
2900 | 2900 | function getHTML() { |
2901 | | - global $wgLang, $wgMessageCache, $wgUseFileCache, $wgShowDBErrorBacktrace; |
| 2901 | + global $wgLang, $wgUseFileCache, $wgShowDBErrorBacktrace; |
2902 | 2902 | |
2903 | 2903 | $sorry = 'Sorry! This site is experiencing technical difficulties.'; |
2904 | 2904 | $again = 'Try waiting a few minutes and reloading.'; |
— | — | @@ -2910,9 +2910,7 @@ |
2911 | 2911 | } |
2912 | 2912 | |
2913 | 2913 | # No database access |
2914 | | - if ( is_object( $wgMessageCache ) ) { |
2915 | | - $wgMessageCache->disable(); |
2916 | | - } |
| 2914 | + MessageCache::singleton()->disable(); |
2917 | 2915 | |
2918 | 2916 | if ( trim( $this->error ) == '' ) { |
2919 | 2917 | $this->error = $this->db->getProperty( 'mServer' ); |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -387,9 +387,6 @@ |
388 | 388 | $wgOut = new StubObject( 'wgOut', 'OutputPage' ); |
389 | 389 | $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); |
390 | 390 | |
391 | | -$wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', |
392 | | - array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) ); |
393 | | - |
394 | 391 | if ( !is_object( $wgAuth ) ) { |
395 | 392 | $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' ); |
396 | 393 | wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) ); |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | * @private |
126 | 126 | */ |
127 | 127 | function getContent( $def_text = '' ) { |
128 | | - global $wgOut, $wgRequest, $wgParser, $wgContLang, $wgMessageCache; |
| 128 | + global $wgOut, $wgRequest, $wgParser, $wgContLang; |
129 | 129 | |
130 | 130 | wfProfileIn( __METHOD__ ); |
131 | 131 | # Get variables from query string :P |
— | — | @@ -141,7 +141,7 @@ |
142 | 142 | if ( !$this->mTitle->exists() ) { |
143 | 143 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
144 | 144 | # If this is a system message, get the default text. |
145 | | - list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); |
| 145 | + list( $message, $lang ) = MessageCache::singleton()->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) ); |
146 | 146 | $text = wfMsgGetKey( $message, false, $lang, false ); |
147 | 147 | if( wfEmptyMsg( $message, $text ) ) |
148 | 148 | $text = $this->getPreloadedText( $preload ); |
— | — | @@ -1887,7 +1887,7 @@ |
1888 | 1888 | * @return string |
1889 | 1889 | */ |
1890 | 1890 | function getPreviewText() { |
1891 | | - global $wgOut, $wgUser, $wgParser, $wgMessageCache; |
| 1891 | + global $wgOut, $wgUser, $wgParser; |
1892 | 1892 | |
1893 | 1893 | wfProfileIn( __METHOD__ ); |
1894 | 1894 | |
— | — | @@ -1956,7 +1956,7 @@ |
1957 | 1957 | |
1958 | 1958 | // Parse mediawiki messages with correct target language |
1959 | 1959 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1960 | | - list( /* $unused */, $lang ) = $wgMessageCache->figureMessage( $this->mTitle->getText() ); |
| 1960 | + list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $this->mTitle->getText() ); |
1961 | 1961 | $obj = wfGetLangObj( $lang ); |
1962 | 1962 | $parserOptions->setTargetLanguage( $obj ); |
1963 | 1963 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -3193,20 +3193,19 @@ |
3194 | 3194 | $u->doUpdate(); |
3195 | 3195 | } |
3196 | 3196 | # Update message cache for interface messages |
3197 | | - global $wgMessageCache; |
3198 | 3197 | if ( $this->getNamespace() == NS_MEDIAWIKI ) { |
3199 | 3198 | # @bug 17860: old article can be deleted, if this the case, |
3200 | 3199 | # delete it from message cache |
3201 | 3200 | if ( $this->getArticleID() === 0 ) { |
3202 | | - $wgMessageCache->replace( $this->getDBkey(), false ); |
| 3201 | + MessageCache::singleton()->replace( $this->getDBkey(), false ); |
3203 | 3202 | } else { |
3204 | 3203 | $oldarticle = new Article( $this ); |
3205 | | - $wgMessageCache->replace( $this->getDBkey(), $oldarticle->getContent() ); |
| 3204 | + MessageCache::singleton()->replace( $this->getDBkey(), $oldarticle->getContent() ); |
3206 | 3205 | } |
3207 | 3206 | } |
3208 | 3207 | if ( $nt->getNamespace() == NS_MEDIAWIKI ) { |
3209 | 3208 | $newarticle = new Article( $nt ); |
3210 | | - $wgMessageCache->replace( $nt->getDBkey(), $newarticle->getContent() ); |
| 3209 | + MessageCache::singleton()->replace( $nt->getDBkey(), $newarticle->getContent() ); |
3211 | 3210 | } |
3212 | 3211 | |
3213 | 3212 | global $wgUser; |
Index: trunk/phase3/includes/Message.php |
— | — | @@ -385,8 +385,7 @@ |
386 | 386 | * @return Wikitext with {{-constructs replaced with their values. |
387 | 387 | */ |
388 | 388 | protected function transformText( $string ) { |
389 | | - global $wgMessageCache; |
390 | | - return $wgMessageCache->transform( $string, $this->interface, $this->language ); |
| 389 | + return MessageCache::singleton()->transform( $string, $this->interface, $this->language ); |
391 | 390 | } |
392 | 391 | |
393 | 392 | /** |
— | — | @@ -407,17 +406,17 @@ |
408 | 407 | */ |
409 | 408 | protected function fetchMessage() { |
410 | 409 | if ( !isset( $this->message ) ) { |
411 | | - global $wgMessageCache; |
| 410 | + $cache = MessageCache::singleton(); |
412 | 411 | if ( is_array($this->key) ) { |
413 | 412 | foreach ( $this->key as $key ) { |
414 | | - $message = $wgMessageCache->get( $key, $this->useDatabase, $this->language ); |
| 413 | + $message = $cache->get( $key, $this->useDatabase, $this->language ); |
415 | 414 | if ( $message !== false && $message !== '' ) { |
416 | 415 | break; |
417 | 416 | } |
418 | 417 | } |
419 | 418 | $this->message = $message; |
420 | 419 | } else { |
421 | | - $this->message = $wgMessageCache->get( $this->key, $this->useDatabase, $this->language ); |
| 420 | + $this->message = $cache->get( $this->key, $this->useDatabase, $this->language ); |
422 | 421 | } |
423 | 422 | } |
424 | 423 | return $this->message; |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -842,13 +842,8 @@ |
843 | 843 | * |
844 | 844 | */ |
845 | 845 | function parseCachedTable( $code, $subpage = '', $recursive = true ) { |
846 | | - global $wgMessageCache; |
847 | 846 | static $parsed = array(); |
848 | 847 | |
849 | | - if ( !is_object( $wgMessageCache ) ) { |
850 | | - return array(); |
851 | | - } |
852 | | - |
853 | 848 | $key = 'Conversiontable/' . $code; |
854 | 849 | if ( $subpage ) { |
855 | 850 | $key .= '/' . $subpage; |
— | — | @@ -858,7 +853,7 @@ |
859 | 854 | } |
860 | 855 | |
861 | 856 | if ( strpos( $code, '/' ) === false ) { |
862 | | - $txt = $wgMessageCache->get( 'Conversiontable', true, $code ); |
| 857 | + $txt = MessageCache::singleton()->get( 'Conversiontable', true, $code ); |
863 | 858 | if ( $txt === false ) { |
864 | 859 | # FIXME: this method doesn't seem to be expecting |
865 | 860 | # this possible outcome... |
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -44,8 +44,13 @@ |
45 | 45 | $parser->getOptions()->setTargetLanguage( Language::factory( $code ) ); |
46 | 46 | $name = $page->getPageDisplayTitle( $code ); |
47 | 47 | if ( $name ) { |
48 | | - global $wgMessageCache; |
49 | | - $name = $wgMessageCache->transform( $name, false, Language::factory( $code ) ); |
| 48 | + if ( method_exists( 'MessageCache', 'singleton' ) ) { |
| 49 | + $cache = MessageCache::singleton(); |
| 50 | + } else { |
| 51 | + global $wgMessageCache; |
| 52 | + $cache = $wgMessageCache; |
| 53 | + } |
| 54 | + $name = $cache->transform( $name, false, Language::factory( $code ) ); |
50 | 55 | $parser->getOutput()->setDisplayTitle( $name ); |
51 | 56 | } |
52 | 57 | } |
Index: trunk/extensions/ErrorHandler/ErrorHandler.php |
— | — | @@ -206,16 +206,8 @@ |
207 | 207 | */ |
208 | 208 | function efErrorHandlerGetMessage(){ |
209 | 209 | static $messages = false; |
210 | | - static $loaded = false; |
211 | 210 | $args = func_get_args(); |
212 | | - if( !$loaded ){ |
213 | | - global $wgMessageCache; |
214 | | - if( function_exists( 'wfMsgExt' ) && is_object( $wgMessageCache ) ){ |
215 | | - $loaded = true; |
216 | | - wfLoadExtensionMessages( 'ErrorHandler' ); |
217 | | - } |
218 | | - } |
219 | | - if( $loaded ){ |
| 211 | + if( function_exists( 'wfMsgExt' ) ){ |
220 | 212 | global $wgTitle; |
221 | 213 | $msg = array_shift( $args ); |
222 | 214 | $opts = array( 'replaceafter' ); |