resourceloader: Add content hash to static debug urls
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 12 Feb 2016 23:33:45 +0000 (00:33 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 20 Feb 2016 22:40:44 +0000 (22:40 +0000)
This way, they automatically bypass any stale client or server cache.

Remove an old wfExpandUrl() call that would interfere with
transformResourcePath()'s ability to recognise the path.

Expanding the url there wasn't needed anyway. Whether it's on a separate host
(eg. bits.wikimedia.org), or path-absolute, either way works as-is.

Bug: T90983
Change-Id: I64eb3291adcfc3733ef96690399c09c06e19b3aa

includes/resourceloader/ResourceLoaderFileModule.php

index b31e8dc..6924d31 100644 (file)
@@ -341,10 +341,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        $remoteBasePath = (string)$options['remoteBasePath'];
                }
 
-               // Make sure the remote base path is a complete valid URL,
-               // but possibly protocol-relative to avoid cache pollution
-               $remoteBasePath = wfExpandUrl( $remoteBasePath, PROTO_RELATIVE );
-
                return [ $localBasePath, $remoteBasePath ];
        }
 
@@ -366,7 +362,10 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
        public function getScriptURLsForDebug( ResourceLoaderContext $context ) {
                $urls = [];
                foreach ( $this->getScriptFiles( $context ) as $file ) {
-                       $urls[] = $this->getRemotePath( $file );
+                       $urls[] = OutputPage::transformResourcePath(
+                               $this->getConfig(),
+                               $this->getRemotePath( $file )
+                       );
                }
                return $urls;
        }
@@ -412,7 +411,10 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                foreach ( $this->getStyleFiles( $context ) as $mediaType => $list ) {
                        $urls[$mediaType] = [];
                        foreach ( $list as $file ) {
-                               $urls[$mediaType][] = $this->getRemotePath( $file );
+                               $urls[$mediaType][] = OutputPage::transformResourcePath(
+                                       $this->getConfig(),
+                                       $this->getRemotePath( $file )
+                               );
                        }
                }
                return $urls;