search: Fix DYM typos in widget
[lhc/web/wiklou.git] / includes / cache / MessageCache.php
index f09b5bf..a08b897 100644 (file)
@@ -107,15 +107,16 @@ class MessageCache {
        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()
                        );
                }
 
@@ -550,6 +551,7 @@ class MessageCache {
                # 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;
        }
@@ -581,10 +583,11 @@ class MessageCache {
                        // 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(
@@ -592,7 +595,7 @@ class MessageCache {
                                );
                                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;
                                }
@@ -774,13 +777,12 @@ class MessageCache {
         *   - 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
@@ -792,13 +794,6 @@ class MessageCache {
                        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 );
 
@@ -1028,14 +1023,15 @@ class MessageCache {
         * @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 );
@@ -1052,7 +1048,7 @@ class MessageCache {
                                                        $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;