Merge "Add support for 'es-formal'"
[lhc/web/wiklou.git] / includes / cache / MessageCache.php
index d6e9b74..2d85d69 100644 (file)
@@ -156,22 +156,22 @@ class MessageCache {
        }
 
        /**
-        * @param WANObjectCache $wanCache WAN cache instance
-        * @param BagOStuff $clusterCache Cluster cache instance
-        * @param BagOStuff $srvCache Server cache instance
+        * @param WANObjectCache $wanCache
+        * @param BagOStuff $clusterCache
+        * @param BagOStuff $serverCache
         * @param bool $useDB Whether to look for message overrides (e.g. MediaWiki: pages)
         * @param int $expiry Lifetime for cache. @see $mExpiry.
         */
        public function __construct(
                WANObjectCache $wanCache,
                BagOStuff $clusterCache,
-               BagOStuff $srvCache,
+               BagOStuff $serverCache,
                $useDB,
                $expiry
        ) {
                $this->wanCache = $wanCache;
                $this->clusterCache = $clusterCache;
-               $this->srvCache = $srvCache;
+               $this->srvCache = $serverCache;
 
                $this->mDisable = !$useDB;
                $this->mExpiry = $expiry;
@@ -191,23 +191,15 @@ class MessageCache {
                                // ParserOptions for it. And don't cache this ParserOptions
                                // either.
                                $po = ParserOptions::newFromAnon();
-                               $po->setEditSection( false );
                                $po->setAllowUnsafeRawHtml( false );
-                               $po->setWrapOutputClass( false );
                                return $po;
                        }
 
                        $this->mParserOptions = new ParserOptions;
-                       $this->mParserOptions->setEditSection( false );
                        // Messages may take parameters that could come
                        // from malicious sources. As a precaution, disable
                        // the <html> parser tag when parsing messages.
                        $this->mParserOptions->setAllowUnsafeRawHtml( false );
-                       // Wrapping messages in an extra <div> is probably not expected. If
-                       // they're outside the content area they probably shouldn't be
-                       // targeted by CSS that's targeting the parser output, and if
-                       // they're inside they already are from the outer div.
-                       $this->mParserOptions->setWrapOutputClass( false );
                }
 
                return $this->mParserOptions;
@@ -621,7 +613,7 @@ class MessageCache {
                                // load() calls do try to refresh the cache with replica DB data
                                $this->mCache[$code]['LATEST'] = time();
                                // Pre-emptively update the local datacenter cache so things like edit filter and
-                               // blacklist changes are reflect immediately, as these often use MediaWiki: pages.
+                               // blacklist changes are reflected immediately; these often use MediaWiki: pages.
                                // The datacenter handling replace() calls should be the same one handling edits
                                // as they require HTTP POST.
                                $this->saveToCaches( $this->mCache[$code], 'all', $code );
@@ -914,7 +906,7 @@ class MessageCache {
                if ( $useDB ) {
                        $uckey = $wgContLang->ucfirst( $lckey );
 
-                       if ( !isset( $alreadyTried[ $langcode ] ) ) {
+                       if ( !isset( $alreadyTried[$langcode] ) ) {
                                $message = $this->getMsgFromNamespace(
                                        $this->getMessagePageName( $langcode, $uckey ),
                                        $langcode
@@ -923,7 +915,7 @@ class MessageCache {
                                if ( $message !== false ) {
                                        return $message;
                                }
-                               $alreadyTried[ $langcode ] = true;
+                               $alreadyTried[$langcode] = true;
                        }
                } else {
                        $uckey = null;
@@ -940,7 +932,7 @@ class MessageCache {
                        $fallbackChain = Language::getFallbacksFor( $langcode );
 
                        foreach ( $fallbackChain as $code ) {
-                               if ( isset( $alreadyTried[ $code ] ) ) {
+                               if ( isset( $alreadyTried[$code] ) ) {
                                        continue;
                                }
 
@@ -950,7 +942,7 @@ class MessageCache {
                                if ( $message !== false ) {
                                        return $message;
                                }
-                               $alreadyTried[ $code ] = true;
+                               $alreadyTried[$code] = true;
                        }
                }
 
@@ -993,13 +985,12 @@ class MessageCache {
                if ( isset( $this->mCache[$code][$title] ) ) {
                        $entry = $this->mCache[$code][$title];
                        if ( substr( $entry, 0, 1 ) === ' ' ) {
-                               // The message exists, so make sure a string is returned.
+                               // The message exists and is not '!TOO BIG'
                                return (string)substr( $entry, 1 );
                        } elseif ( $entry === '!NONEXISTENT' ) {
                                return false;
-                       } elseif ( $entry === '!TOO BIG' ) {
-                               // Fall through and try invididual message cache below
                        }
+                       // Fall through and try invididual message cache below
                } else {
                        // XXX: This is not cached in process cache, should it?
                        $message = false;
@@ -1085,11 +1076,11 @@ class MessageCache {
        /**
         * @param string $message
         * @param bool $interface
-        * @param string $language Language code
+        * @param Language $language
         * @param Title $title
         * @return string
         */
-       function transform( $message, $interface = false, $language = null, $title = null ) {
+       public function transform( $message, $interface = false, $language = null, $title = null ) {
                // Avoid creating parser if nothing to transform
                if ( strpos( $message, '{{' ) === false ) {
                        return $message;
@@ -1118,7 +1109,7 @@ class MessageCache {
        /**
         * @return Parser
         */
-       function getParser() {
+       public function getParser() {
                global $wgParser, $wgParserConf;
 
                if ( !$this->mParser && isset( $wgParser ) ) {
@@ -1126,7 +1117,7 @@ class MessageCache {
                        $wgParser->firstCallInit();
                        # Clone it and store it
                        $class = $wgParserConf['class'];
-                       if ( $class == 'ParserDiffTest' ) {
+                       if ( $class == ParserDiffTest::class ) {
                                # Uncloneable
                                $this->mParser = new $class( $wgParserConf );
                        } else {
@@ -1182,11 +1173,11 @@ class MessageCache {
                return $res;
        }
 
-       function disable() {
+       public function disable() {
                $this->mDisable = true;
        }
 
-       function enable() {
+       public function enable() {
                $this->mDisable = false;
        }