* @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 ) {
$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
* @return void
*/
public function loadFromFileCache( IContextSource $context, $mode = self::MODE_NORMAL ) {
- global $wgContLang;
$config = MediaWikiServices::getInstance()->getMainConfig();
wfDebug( __METHOD__ . "()\n" );
$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' );
}
// 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;
}
/**