public static function singleton() {
if ( self::$instance === null ) {
global $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgUseLocalMessageCache;
+ $services = MediaWikiServices::getInstance();
self::$instance = new self(
- MediaWikiServices::getInstance()->getMainWANObjectCache(),
+ $services->getMainWANObjectCache(),
wfGetMessageCacheStorage(),
$wgUseLocalMessageCache
- ? MediaWikiServices::getInstance()->getLocalServerObjectCache()
+ ? $services->getLocalServerObjectCache()
: new EmptyBagOStuff(),
$wgUseDatabaseMessages,
$wgMsgCacheExpiry,
- MediaWikiServices::getInstance()->getContentLanguage()
+ $services->getContentLanguage()
);
}
# stored and fetched from memcache.
$cache['HASH'] = md5( serialize( $cache ) );
$cache['EXPIRY'] = wfTimestamp( TS_MW, time() + $this->mExpiry );
+ unset( $cache['EXCESSIVE'] ); // only needed for hash
return $cache;
}
// Ignore $wgMaxMsgCacheEntrySize so the process cache is up to date
$this->cache->setField( $code, $title, ' ' . $text );
}
+ $fname = __METHOD__;
// (b) Update the shared caches in a deferred update with a fresh DB snapshot
DeferredUpdates::addCallableUpdate(
- function () use ( $title, $msg, $code ) {
+ function () use ( $title, $msg, $code, $fname ) {
global $wgMaxMsgCacheEntrySize;
// Allow one caller at a time to avoid race conditions
$scopedLock = $this->getReentrantScopedLock(
);
if ( !$scopedLock ) {
LoggerFactory::getInstance( 'MessageCache' )->error(
- __METHOD__ . ': could not acquire lock to update {title} ({code})',
+ $fname . ': could not acquire lock to update {title} ({code})',
[ 'title' => $title, 'code' => $code ] );
return;
}
* - If boolean and false, create object from the current users language
* - If boolean and true, create object from the wikis content language
* - If language object, use it as given
- * @param bool $isFullKey Specifies whether $key is a two part key "msg/lang".
*
* @throws MWException When given an invalid key
* @return string|bool False if the message doesn't exist, otherwise the
* message (which can be empty)
*/
- function get( $key, $useDB = true, $langcode = true, $isFullKey = false ) {
+ function get( $key, $useDB = true, $langcode = true ) {
if ( is_int( $key ) ) {
// Fix numerical strings that somehow become ints
// on their way here
return false;
}
- // For full keys, get the language code from the key
- $pos = strrpos( $key, '/' );
- if ( $isFullKey && $pos !== false ) {
- $langcode = substr( $key, $pos + 1 );
- $key = substr( $key, 0, $pos );
- }
-
// Normalise title-case input (with some inlining)
$lckey = self::normalizeKey( $key );
* @return string Either " <MESSAGE>" or "!NONEXISTANT"
*/
private function loadCachedMessagePageEntry( $dbKey, $code, $hash ) {
+ $fname = __METHOD__;
return $this->srvCache->getWithSetCallback(
$this->srvCache->makeKey( 'messages-big', $hash, $dbKey ),
IExpiringStore::TTL_MINUTE,
- function () use ( $code, $dbKey, $hash ) {
+ function () use ( $code, $dbKey, $hash, $fname ) {
return $this->wanCache->getWithSetCallback(
$this->bigMessageCacheKey( $hash, $dbKey ),
$this->mExpiry,
- function ( $oldValue, &$ttl, &$setOpts ) use ( $dbKey, $code ) {
+ function ( $oldValue, &$ttl, &$setOpts ) use ( $dbKey, $code, $fname ) {
// Try loading the message from the database
$dbr = wfGetDB( DB_REPLICA );
$setOpts += Database::getCacheSetOptions( $dbr );
$message = $this->getMessageTextFromContent( $content );
} else {
LoggerFactory::getInstance( 'MessageCache' )->warning(
- __METHOD__ . ': failed to load page text for \'{titleKey}\'',
+ $fname . ': failed to load page text for \'{titleKey}\'',
[ 'titleKey' => $dbKey, 'code' => $code ]
);
$message = null;