Merge "registration: Avoid double slashes in localBasePath"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 18 Feb 2016 18:48:07 +0000 (18:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 18 Feb 2016 18:48:07 +0000 (18:48 +0000)
includes/registration/ExtensionProcessor.php
tests/phpunit/includes/registration/ExtensionProcessorTest.php

index 2318c87..fe9304f 100644 (file)
@@ -253,14 +253,24 @@ class ExtensionProcessor implements Processor {
                        ? $info['ResourceFileModulePaths']
                        : false;
                if ( isset( $defaultPaths['localBasePath'] ) ) {
-                       $defaultPaths['localBasePath'] = "$dir/{$defaultPaths['localBasePath']}";
+                       if ( $defaultPaths['localBasePath'] === '' ) {
+                               // Avoid double slashes (e.g. /extensions/Example//path)
+                               $defaultPaths['localBasePath'] = $dir;
+                       } else {
+                               $defaultPaths['localBasePath'] = "$dir/{$defaultPaths['localBasePath']}";
+                       }
                }
 
                foreach ( [ 'ResourceModules', 'ResourceModuleSkinStyles' ] as $setting ) {
                        if ( isset( $info[$setting] ) ) {
                                foreach ( $info[$setting] as $name => $data ) {
                                        if ( isset( $data['localBasePath'] ) ) {
-                                               $data['localBasePath'] = "$dir/{$data['localBasePath']}";
+                                               if ( $data['localBasePath'] === '' ) {
+                                                       // Avoid double slashes (e.g. /extensions/Example//path)
+                                                       $data['localBasePath'] = $dir;
+                                               } else {
+                                                       $data['localBasePath'] = "$dir/{$data['localBasePath']}";
+                                               }
                                        }
                                        if ( $defaultPaths ) {
                                                $data += $defaultPaths;
index 7f84e33..35aca48 100644 (file)
@@ -218,7 +218,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
        }
 
        public static function provideExtractResourceLoaderModules() {
-               $dir = __DIR__ . '/FooBar/';
+               $dir = __DIR__ . '/FooBar';
                return [
                        // Generic module with localBasePath/remoteExtPath specified
                        [
@@ -285,7 +285,7 @@ class ExtensionProcessorTest extends MediaWikiTestCase {
                                                ],
                                                'test.bar' => [
                                                        'styles' => 'bar.js',
-                                                       'localBasePath' => $dir . 'subdir',
+                                                       'localBasePath' => "$dir/subdir",
                                                        'remoteExtPath' => 'FooBar/subdir',
                                                ],
                                                'test.class' => [