}
# Loading code starts
- wfProfileIn( __METHOD__ );
$success = false; # Keep track of success
$staleCache = false; # a cache array with expired data, or false if none has been loaded
$where = array(); # Debug info, delayed to avoid spamming debug log too much
# Hash of the contents is stored in memcache, to detect if local cache goes
# out of date (e.g. due to replace() on some other server)
if ( $wgUseLocalMessageCache ) {
- wfProfileIn( __METHOD__ . '-fromlocal' );
$hash = $this->mMemc->get( wfMemcKey( 'messages', $code, 'hash' ) );
if ( $hash ) {
$this->mCache[$code] = $cache;
}
}
- wfProfileOut( __METHOD__ . '-fromlocal' );
}
if ( !$success ) {
# the lock can't be acquired, wait for the other thread to finish
# and then try the global cache a second time.
for ( $failedAttempts = 0; $failedAttempts < 2; $failedAttempts++ ) {
- wfProfileIn( __METHOD__ . '-fromcache' );
$cache = $this->mMemc->get( $cacheKey );
if ( !$cache ) {
$where[] = 'global cache is empty';
$success = true;
}
- wfProfileOut( __METHOD__ . '-fromcache' );
-
if ( $success ) {
# Done, no need to retry
break;
}
$info = implode( ', ', $where );
wfDebugLog( 'MessageCache', __METHOD__ . ": Loading $code... $info\n" );
- wfProfileOut( __METHOD__ );
return $success;
}
* @return array Loaded messages for storing in caches.
*/
function loadFromDB( $code ) {
- wfProfileIn( __METHOD__ );
global $wgMaxMsgCacheEntrySize, $wgLanguageCode, $wgAdaptiveMessageCache;
$dbr = wfGetDB( DB_SLAVE );
$cache = array();
$cache['VERSION'] = MSG_CACHE_VERSION;
$cache['EXPIRY'] = wfTimestamp( TS_MW, time() + $this->mExpiry );
- wfProfileOut( __METHOD__ );
return $cache;
}
*/
public function replace( $title, $text ) {
global $wgMaxMsgCacheEntrySize;
- wfProfileIn( __METHOD__ );
if ( $this->mDisable ) {
- wfProfileOut( __METHOD__ );
return;
}
global $wgContLang;
MessageBlobStore::getInstance()->updateMessage( $wgContLang->lcfirst( $msg ) );
- wfRunHooks( 'MessageCacheReplace', array( $title, $text ) );
+ Hooks::run( 'MessageCacheReplace', array( $title, $text ) );
- wfProfileOut( __METHOD__ );
}
/**
* @return bool
*/
protected function saveToCaches( $cache, $dest, $code = false ) {
- wfProfileIn( __METHOD__ );
global $wgUseLocalMessageCache;
$cacheKey = wfMemcKey( 'messages', $code );
$this->saveToLocal( $serialized, $hash, $code );
}
- wfProfileOut( __METHOD__ );
-
return $success;
}
function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) {
global $wgContLang;
- $section = new ProfileSection( __METHOD__ );
-
if ( is_int( $key ) ) {
// Fix numerical strings that somehow become ints
// on their way here
$lckey = $wgContLang->lcfirst( $lckey );
}
- wfRunHooks( 'MessageCache::get', array( &$lckey ) );
+ Hooks::run( 'MessageCache::get', array( &$lckey ) );
if ( ord( $lckey ) < 128 ) {
$uckey = ucfirst( $lckey );
} else {
// XXX: This is not cached in process cache, should it?
$message = false;
- wfRunHooks( 'MessagesPreLoad', array( $title, &$message ) );
+ Hooks::run( 'MessagesPreLoad', array( $title, &$message ) );
if ( $message !== false ) {
return $message;
}
$popts->setInterfaceMessage( $interface );
$popts->setTargetLanguage( $language );
- wfProfileIn( __METHOD__ );
if ( !$title || !$title instanceof Title ) {
global $wgTitle;
+ wfDebugLog( 'GlobalTitleFail', __METHOD__ . ' called by ' . wfGetAllCallers( 5 ) . ' with no title set.' );
$title = $wgTitle;
}
// Sometimes $wgTitle isn't set either...
$res = $parser->parse( $text, $title, $popts, $linestart );
$this->mInParser = false;
- wfProfileOut( __METHOD__ );
-
return $res;
}