Revert "resourceloader: Add support for variables in WikiModule"
authorKrinkle <krinklemail@gmail.com>
Thu, 9 Jun 2016 19:27:34 +0000 (19:27 +0000)
committerKrinkle <krinklemail@gmail.com>
Thu, 9 Jun 2016 19:27:34 +0000 (19:27 +0000)
No longer needed per doing Ic137cb494ba23 in a different way.
This may be useful to revisit, but for now preferring to keep
simplicity and removing this unused option.

This reverts commit 9e217bf42d73ef2dfcdecfe3a753cf8d702a18fd.

Change-Id: I9c0c316a3b58a3d0a3d3282dd74c7fa4eef8e378

includes/resourceloader/ResourceLoaderWikiModule.php
tests/phpunit/ResourceLoaderTestCase.php
tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php

index e3ada8e..a3f8825 100644 (file)
@@ -61,9 +61,6 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
        // Group of module
        protected $group;
 
-       // Whether to enable variable expansion (e.g. "{skin}")
-       protected $allowVariables = false;
-
        /**
         * @param array $options For back-compat, this can be omitted in favour of overwriting getPages.
         */
@@ -79,7 +76,6 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                                case 'scripts':
                                case 'group':
                                case 'targets':
-                               case 'allowVariables':
                                        $this->{$member} = $option;
                                        break;
                        }
@@ -109,30 +105,19 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                // Filter out pages from origins not allowed by the current wiki configuration.
                if ( $config->get( 'UseSiteJs' ) ) {
                        foreach ( $this->scripts as $script ) {
-                               $page = $this->expandVariables( $context, $script );
-                               $pages[$page] = [ 'type' => 'script' ];
+                               $pages[$script] = [ 'type' => 'script' ];
                        }
                }
 
                if ( $config->get( 'UseSiteCss' ) ) {
                        foreach ( $this->styles as $style ) {
-                               $page = $this->expandVariables( $context, $style );
-                               $pages[$page] = [ 'type' => 'style' ];
+                               $pages[$style] = [ 'type' => 'style' ];
                        }
                }
 
                return $pages;
        }
 
-       private function expandVariables( ResourceLoaderContext $context, $pageName ) {
-               if ( !$this->allowVariables ) {
-                       return $pageName;
-               }
-               return strtr( $pageName, [
-                       '{skin}' => $context->getSkin()
-               ] );
-       }
-
        /**
         * Get group name
         *
index 275ed27..85bf954 100644 (file)
@@ -30,9 +30,6 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
                        // For ResourceLoader::inDebugMode since it doesn't have context
                        'ResourceLoaderDebug' => true,
 
-                       // For ResourceLoaderContext::newDummyContext()
-                       'DefaultSkin' => 'vector',
-
                        // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
                        'CacheEpoch' => '20140101000000',
 
index e6bb5a7..85834d7 100644 (file)
@@ -49,12 +49,6 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                        'scripts' => [ 'MediaWiki:Common.js' ],
                ];
 
-               $variableParams = [
-                       'allowVariables' => true,
-                       'styles' => [ 'MediaWiki:Common.css', 'MediaWiki:{skin}.css' ],
-                       'scripts' => [ 'MediaWiki:Common.js', 'MediaWiki:{skin}.js' ],
-               ];
-
                return [
                        [ [], new HashConfig( $settings ), [] ],
                        [ $params, new HashConfig( $settings ), [
@@ -73,12 +67,6 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase {
                                ),
                                []
                        ],
-                       [ $variableParams, new HashConfig( $settings ), [
-                               'MediaWiki:Common.js' => [ 'type' => 'script' ],
-                               'MediaWiki:vector.js' => [ 'type' => 'script' ],
-                               'MediaWiki:Common.css' => [ 'type' => 'style' ],
-                               'MediaWiki:vector.css' => [ 'type' => 'style' ]
-                       ] ],
                ];
        }