Merge "rest: Use ParamValidator library, add BodyValidator"
[lhc/web/wiklou.git] / includes / cache / HTMLFileCache.php
index f8cd754..ab78ee4 100644 (file)
@@ -91,14 +91,9 @@ class HTMLFileCache extends FileCacheBase {
         * @return bool
         */
        public static function useFileCache( IContextSource $context, $mode = self::MODE_NORMAL ) {
-               global $wgContLang;
                $config = MediaWikiServices::getInstance()->getMainConfig();
 
                if ( !$config->get( 'UseFileCache' ) && $mode !== self::MODE_REBUILD ) {
-                       return false;
-               } elseif ( $config->get( 'DebugToolbar' ) ) {
-                       wfDebug( "HTML file cache skipped. \$wgDebugToolbar on\n" );
-
                        return false;
                }
 
@@ -124,14 +119,13 @@ class HTMLFileCache extends FileCacheBase {
                $ulang = $context->getLanguage();
 
                // Check that there are no other sources of variation
-               if ( $user->getId() || !$ulang->equals( $wgContLang ) ) {
+               if ( $user->getId() ||
+                       !$ulang->equals( MediaWikiServices::getInstance()->getContentLanguage() ) ) {
                        return false;
                }
 
-               if ( $mode === self::MODE_NORMAL ) {
-                       if ( $user->getNewtalk() ) {
-                               return false;
-                       }
+               if ( ( $mode === self::MODE_NORMAL ) && $user->getNewtalk() ) {
+                       return false;
                }
 
                // Allow extensions to disable caching
@@ -145,7 +139,6 @@ class HTMLFileCache extends FileCacheBase {
         * @return void
         */
        public function loadFromFileCache( IContextSource $context, $mode = self::MODE_NORMAL ) {
-               global $wgContLang;
                $config = MediaWikiServices::getInstance()->getMainConfig();
 
                wfDebug( __METHOD__ . "()\n" );
@@ -158,7 +151,8 @@ class HTMLFileCache extends FileCacheBase {
 
                $context->getOutput()->sendCacheControl();
                header( "Content-Type: {$config->get( 'MimeType' )}; charset=UTF-8" );
-               header( "Content-Language: {$wgContLang->getHtmlCode()}" );
+               header( 'Content-Language: ' .
+                       MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() );
                if ( $this->useGzip() ) {
                        if ( wfClientAcceptsGzip() ) {
                                header( 'Content-Encoding: gzip' );
@@ -211,18 +205,14 @@ class HTMLFileCache extends FileCacheBase {
                }
 
                // gzip output to buffer as needed and set headers...
-               if ( $this->useGzip() ) {
-                       // @todo Ugly wfClientAcceptsGzip() function - use context!
-                       if ( wfClientAcceptsGzip() ) {
-                               header( 'Content-Encoding: gzip' );
+               // @todo Ugly wfClientAcceptsGzip() function - use context!
+               if ( $this->useGzip() && wfClientAcceptsGzip() ) {
+                       header( 'Content-Encoding: gzip' );
 
-                               return $compressed;
-                       } else {
-                               return $text;
-                       }
-               } else {
-                       return $text;
+                       return $compressed;
                }
+
+               return $text;
        }
 
        /**