Merge "clientpool: refactor Redis authentication error handling"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 6c45d9c..c51f6f8 100644 (file)
@@ -468,9 +468,9 @@ class OutputPage extends ContextSource {
         * Internal use only. Use OutputPage::addModules() if possible.
         *
         * @param string $file URL to file (absolute path, protocol-relative, or full url)
-        * @param string $version Style version of the file. Defaults to $wgStyleVersion
+        * @param string $unused Previously used to change the cache-busting query parameter
         */
-       public function addScriptFile( $file, $version = null ) {
+       public function addScriptFile( $file, $unused = null ) {
                if ( substr( $file, 0, 1 ) !== '/' && !preg_match( '#^[a-z]*://#i', $file ) ) {
                        // This is not an absolute path, protocol-relative url, or full scheme url,
                        // presumed to be an old call intended to include a file from /w/skins/common,
@@ -478,11 +478,7 @@ class OutputPage extends ContextSource {
                        wfDeprecated( __METHOD__, '1.24' );
                        return;
                }
-               $path = $file;
-               if ( is_null( $version ) ) {
-                       $version = $this->getConfig()->get( 'StyleVersion' );
-               }
-               $this->addScript( Html::linkedScript( wfAppendQuery( $path, $version ), $this->getCSPNonce() ) );
+               $this->addScript( Html::linkedScript( $file, $this->getCSPNonce() ) );
        }
 
        /**
@@ -646,9 +642,7 @@ class OutputPage extends ContextSource {
                        // Register a callback for $this->contentOverrides on the first call
                        $this->addContentOverrideCallback( function ( LinkTarget $target ) {
                                $key = $target->getNamespace() . ':' . $target->getDBkey();
-                               return isset( $this->contentOverrides[$key] )
-                                       ? $this->contentOverrides[$key]
-                                       : null;
+                               return $this->contentOverrides[$key] ?? null;
                        } );
                }
 
@@ -1520,9 +1514,7 @@ class OutputPage extends ContextSource {
                if ( $type == ResourceLoaderModule::TYPE_COMBINED ) {
                        return min( array_values( $this->mAllowedModules ) );
                } else {
-                       return isset( $this->mAllowedModules[$type] )
-                               ? $this->mAllowedModules[$type]
-                               : ResourceLoaderModule::ORIGIN_ALL;
+                       return $this->mAllowedModules[$type] ?? ResourceLoaderModule::ORIGIN_ALL;
                }
        }
 
@@ -2417,10 +2409,6 @@ class OutputPage extends ContextSource {
                $response->header( 'Content-type: ' . $config->get( 'MimeType' ) . '; charset=UTF-8' );
                $response->header( 'Content-language: ' . $wgContLang->getHtmlCode() );
 
-               // Avoid Internet Explorer "compatibility view" in IE 8-10, so that
-               // jQuery etc. can work correctly.
-               $response->header( 'X-UA-Compatible: IE=Edge' );
-
                if ( !$this->mArticleBodyOnly ) {
                        $sk = $this->getSkin();
 
@@ -3666,8 +3654,11 @@ class OutputPage extends ContextSource {
                        $url = $style;
                } else {
                        $config = $this->getConfig();
-                       $url = $config->get( 'StylePath' ) . '/' . $style . '?' .
-                               $config->get( 'StyleVersion' );
+                       // Append file hash as query parameter
+                       $url = self::transformResourcePath(
+                               $config,
+                               $config->get( 'StylePath' ) . '/' . $style
+                       );
                }
 
                $link = Html::linkedStyle( $url, $media );
@@ -3909,7 +3900,7 @@ class OutputPage extends ContextSource {
         */
        public static function setupOOUI( $skinName = 'default', $dir = 'ltr' ) {
                $themes = ResourceLoaderOOUIModule::getSkinThemeMap();
-               $theme = isset( $themes[$skinName] ) ? $themes[$skinName] : $themes['default'];
+               $theme = $themes[$skinName] ?? $themes['default'];
                // For example, 'OOUI\WikimediaUITheme'.
                $themeClass = "OOUI\\{$theme}Theme";
                OOUI\Theme::setSingleton( new $themeClass() );
@@ -3973,12 +3964,8 @@ class OutputPage extends ContextSource {
                uksort( $logosPerDppx, function ( $a , $b ) {
                        $a = floatval( $a );
                        $b = floatval( $b );
-
-                       if ( $a == $b ) {
-                               return 0;
-                       }
                        // Sort from smallest to largest (e.g. 1x, 1.5x, 2x)
-                       return ( $a < $b ) ? -1 : 1;
+                       return $a <=> $b;
                } );
 
                foreach ( $logosPerDppx as $dppx => $src ) {