Merge "Remove deprecated wgResourceLoaderLESSImportPaths"
[lhc/web/wiklou.git] / includes / OutputPage.php
index c7028db..7f72d36 100644 (file)
@@ -463,24 +463,22 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add a JavaScript file out of skins/common, or a given relative path.
+        * Add a JavaScript file to be loaded as `<script>` on this page.
+        *
         * Internal use only. Use OutputPage::addModules() if possible.
         *
-        * @param string $file Filename in skins/common or complete on-server path
-        *              (/foo/bar.js)
-        * @param string $version Style version of the file. Defaults to $wgStyleVersion
+        * @param string $file URL to file (absolute path, protocol-relative, or full url)
+        * @param string $unused Previously used to change the cache-busting query parameter
         */
-       public function addScriptFile( $file, $version = null ) {
-               // See if $file parameter is an absolute URL or begins with a slash
-               if ( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) {
-                       $path = $file;
-               } else {
-                       $path = $this->getConfig()->get( 'StylePath' ) . "/common/{$file}";
-               }
-               if ( is_null( $version ) ) {
-                       $version = $this->getConfig()->get( 'StyleVersion' );
+       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,
+                       // which doesn't exist anymore as of MediaWiki 1.24 per T71277. Ignore.
+                       wfDeprecated( __METHOD__, '1.24' );
+                       return;
                }
-               $this->addScript( Html::linkedScript( wfAppendQuery( $path, $version ), $this->getCSPNonce() ) );
+               $this->addScript( Html::linkedScript( $file, $this->getCSPNonce() ) );
        }
 
        /**
@@ -3664,8 +3662,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 );