r5477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5476‎ | r5477 | r5478 >
Date:02:23, 25 September 2004
Author:zhengzhu
Status:old
Tags:
Comment:
removed caching of UI messages; it does not make sense, after all.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/MessageCache.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -414,19 +414,21 @@
415415 return wfMsgReal( $key, $args, false, true );
416416 }
417417
 418+
418419 /**
419420 * Really get a message
420421 */
421422 function wfMsgReal( $key, $args, $useDB, $forContent=false ) {
422 - global $wgReplacementKeys;
 423+ global $wgReplacementKeys, $wgParser, $wgMsgParserOptions;
 424+
423425 if($forContent) {
424 - global $wgContMessageCache, $wgContLang;
425 - $cache = &$wgContMessageCache;
 426+ global $wgMessageCache, $wgContLang;
 427+ $cache = &$wgMessageCache;
426428 $lang = &$wgContLang;
427429 }
428430 else {
429 - global $wgMessageCache, $wgLang;
430 - $cache = &$wgMessageCache;
 431+ global $wgLang;
 432+ $cache = false;
431433 $lang = &$wgLang;
432434 }
433435
@@ -436,6 +438,9 @@
437439 $message = $cache->get( $key, $useDB );
438440 } elseif (is_object($lang)) {
439441 $message = $lang->getMessage( $key );
 442+ if(strstr($message, '{{' ) !== false) {
 443+ $message = $wgParser->transformMsg($message, $wgMsgParserOptions);
 444+ }
440445 } else {
441446 wfDebug( "No language object when getting $key\n" );
442447 $message = "<$key>";
Index: trunk/phase3/includes/MessageCache.php
@@ -23,12 +23,11 @@
2424 var $mMemcKey, $mKeys, $mParserOptions, $mParser;
2525 var $mExtensionMessages;
2626 var $mInitialised = false;
27 - var $mLang, $mLangCode;
28 - function initialise( &$memCached, $useDB, $expiry, $memcPrefix, $langobj, $langcode) {
 27+
 28+ function initialise( &$memCached, $useDB, $expiry, $memcPrefix) {
2929 $fname = 'MessageCache::initialise';
3030 wfProfileIn( $fname );
31 - $this->mLang = $langobj;
32 - $this->mLangCode = $langcode;
 31+
3332 $this->mUseCache = !is_null( $memCached );
3433 $this->mMemc = &$memCached;
3534 $this->mDisable = !$useDB;
@@ -141,11 +140,11 @@
142141 * Not really needed anymore
143142 */
144143 function getKeys() {
145 - global $wgAllMessagesEn;
 144+ global $wgAllMessagesEn, $wgContLang;
146145 if ( !$this->mKeys ) {
147146 $this->mKeys = array();
148147 foreach ( $wgAllMessagesEn as $key => $value ) {
149 - array_push( $this->mKeys, $this->mLang->ucfirst( $key ) );
 148+ array_push( $this->mKeys, $wgContLang->ucfirst( $key ) );
150149 }
151150 }
152151 return $this->mKeys;
@@ -200,7 +199,7 @@
201200 }
202201
203202 function get( $key, $useDB ) {
204 -
 203+ global $wgContLang, $wgContLanguageCode;
205204 # If uninitialised, someone is trying to call this halfway through Setup.php
206205 if ( !$this->mInitialised ) {
207206 return "<$key>";
@@ -208,7 +207,7 @@
209208
210209 $message = false;
211210 if ( !$this->mDisable && $useDB ) {
212 - $title = $this->mLang->ucfirst( $key );
 211+ $title = $wgContLang->ucfirst( $key );
213212
214213
215214 # Try the cache
@@ -235,12 +234,12 @@
236235 # Try the array in the language object
237236 if ( !$message ) {
238237 wfSuppressWarnings();
239 - $message = $this->mLang->getMessage( $key );
 238+ $message = $wgContLang->getMessage( $key );
240239 wfRestoreWarnings();
241240 }
242241
243242 # Try the English array
244 - if ( !$message && $this->mLangCode != 'en' ) {
 243+ if ( !$message && $wgContLanguageCode != 'en' ) {
245244 wfSuppressWarnings();
246245 $message = Language::getMessage( $key );
247246 wfRestoreWarnings();
Index: trunk/phase3/includes/Setup.php
@@ -80,9 +80,9 @@
8181 global $wgUser, $wgLang, $wgContLang, $wgOut, $wgTitle;
8282 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
8383 global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
84 -global $wgMessageCache, $wgUseMemCached, $wgUseDatabaseMessages, $wgContMessageCach;
 84+global $wgMessageCache, $wgUseMemCached, $wgUseDatabaseMessages;
8585 global $wgMsgCacheExpiry, $wgCommandLineMode;
86 -global $wgBlockCache, $wgParserCache, $wgParser, $wgDBConnections;
 86+global $wgBlockCache, $wgParserCache, $wgParser, $wgDBConnections, $wgMsgParserOptions;
8787 global $wgLoadBalancer, $wgDBservers, $wgDebugDumpSql;
8888 global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, $wgDBtype;
8989 global $wgUseOldExistenceCheck, $wgEnablePersistentLC;
@@ -261,7 +261,8 @@
262262 $wgLanguageCode = $wgUser->getOption('language');
263263
264264 $wgLangClass = 'Language'. str_replace( '-', '_', ucfirst( $wgLanguageCode ) );
265 -if($wgLangClass == $wgContLangClass) {
 265+
 266+if($wgLangClass == $wgContLangClass ) {
266267 $wgLang = &$wgContLang;
267268 }
268269 else {
@@ -273,15 +274,8 @@
274275 wfProfileOut( $fname.'-language' );
275276 wfProfileIn( $fname.'-MessageCache' );
276277
277 -$wgContMessageCache = new MessageCache;
278 -$wgContMessageCache->initialise( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname, $wgContLang, $wgContLanguageCode );
279 -if($wgLangClass == $wgContLangClass) {
280 - $wgMessageCache = &$wgContMessageCache;
281 -}
282 -else {
283 - $wgMessageCache = new MessageCache;
284 - $wgMessageCache->initialise( $messageMemc,false , $wgMsgCacheExpiry, $wgDBname.":$wgLangClass", $wgLang, $wgLanguageCode);
285 -}
 278+$wgMessageCache = new MessageCache;
 279+$wgMessageCache->initialise( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname);
286280
287281 wfProfileOut( $fname.'-MessageCache' );
288282
@@ -298,7 +292,6 @@
299293 # $wgLangClass = $wgContLangClass;
300294 # $wgLanguageCode = $wgContLanguageCode;
301295 # $wgLang = $wgContLang;
302 -# $wgMessageCache = $wgContMessageCache;
303296 #
304297 # TODO: Need to change reference to $wgLang to $wgContLang at proper
305298 # places, including namespaces, dates in signatures, magic words,
@@ -338,6 +331,7 @@
339332 $wgParser = new Parser();
340333 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
341334 $wgDBConnections = array();
 335+$wgMsgParserOptions = ParserOptions::newFromUser($wgUser);
342336 wfSeedRandom();
343337
344338 # Placeholders in case of DB error

Status & tagging log