wfDebug( "MessageCache::load(): loading all messages\n" );
$this->lock();
# Other threads don't need to load the messages if another thread is doing it.
- $success = $this->mMemc->set( $this->mMemcKey, "loading", MSG_LOAD_TIMEOUT );
+ $success = $this->mMemc->add( $this->mMemcKey, "loading", MSG_LOAD_TIMEOUT );
if ( $success ) {
wfProfileIn( $fname.'-load' );
$this->loadFromDB();
}
function get( $key, $useDB, $forcontent=true ) {
- if($forcontent) {
- global $wgContLang, $wgContLanguageCode;
- $lang = $wgContLang;
+ global $wgContLanguageCode;
+ if( $forcontent ) {
+ global $wgContLang;
+ $lang =& $wgContLang;
$langcode = $wgContLanguageCode;
- }
- else {
+ } else {
global $wgLang, $wgLanguageCode;
- $lang = $wgLang;
+ $lang =& $wgLang;
$langcode = $wgLanguageCode;
}
# If uninitialised, someone is trying to call this halfway through Setup.php
- if ( !$this->mInitialised ) {
+ if( !$this->mInitialised ) {
return "<$key>";
}
$message = false;
- if ( !$this->mDisable && $useDB ) {
- $title = $lang->ucfirst( $key )."/$langcode";
-
+ if( !$this->mDisable && $useDB ) {
+ $title = $lang->ucfirst( $key );
+ if( $langcode != $wgContLanguageCode ) {
+ $title .= '/' . $langcode;
+ }
# Try the cache
- if ( $this->mUseCache && $this->mCache && array_key_exists( $title, $this->mCache ) ) {
+ if( $this->mUseCache && $this->mCache && array_key_exists( $title, $this->mCache ) ) {
$message = $this->mCache[$title];
}
+ if ( !$message && $this->mUseCache ) {
+ $message = $this->mMemc->get( $this->mMemcKey . ':' . $title );
+ if( $message ) {
+ $this->mCache[$title] = $message;
+ }
+ }
+
# If it wasn't in the cache, load each message from the DB individually
if ( !$message ) {
$dbr =& wfGetDB( DB_SLAVE );
- $result = $dbr->getArray( 'cur', array('cur_text'),
+ $result = $dbr->selectRow( 'cur', array('cur_text'),
array( 'cur_namespace' => NS_MEDIAWIKI, 'cur_title' => $title ),
'MessageCache::get' );
if ( $result ) {
$message = $result->cur_text;
+ if( $this->mUseCache ) {
+ $this->mCache[$title] = $message;
+ /* individual messages may be often
+ recached until proper purge code exists
+ */
+ $this->mMemc->set( $this->mMemcKey . ':' . $title, $message, 300 );
+ }
}
}
}
# Try the extension array
- if ( !$message ) {
+ if( !$message ) {
$message = @$this->mExtensionMessages[$key];
}
# Try the array in the language object
- if ( !$message ) {
+ if( !$message ) {
wfSuppressWarnings();
$message = $lang->getMessage( $key );
wfRestoreWarnings();
}
# Try the English array
- if ( !$message && $langcode != 'en' ) {
+ if( !$message && $langcode != 'en' ) {
wfSuppressWarnings();
$message = Language::getMessage( $key );
wfRestoreWarnings();
}
# Final fallback
- if ( !$message ) {
+ if( !$message ) {
$message = "<$key>";
}
function transform( $message ) {
if( !$this->mDisableTransform ) {
- if ( strstr( $message, '{{' ) !== false ) {
+ if( strpos( $message, '{{' ) !== false ) {
$message = $this->mParser->transformMsg( $message, $this->mParserOptions );
}
}