From: Fomafix Date: Mon, 10 Jun 2019 17:38:05 +0000 (+0200) Subject: resourceloader: Omit default 'lang' and 'skin' params from load.php urls X-Git-Tag: 1.34.0-rc.0~1432 X-Git-Url: http://git.cyclocoop.org/%22.htmlspecialchars%28%24url_syndic%29.%22?a=commitdiff_plain;h=63fc0a8cc7ee1567c57bfc111c2df982a3d5e03e;p=lhc%2Fweb%2Fwiklou.git resourceloader: Omit default 'lang' and 'skin' params from load.php urls lang=qqx and skin=fallback are the default values. This change removes the default values from the load request of the html5shiv module. Before this change With this change Change-Id: Ie384ce0f7ab1bd0b6c2d3f0ca4a990c3cf3a7f15 --- diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 515f287a6c..e338f93091 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -1709,7 +1709,6 @@ MESSAGE; * @param bool $printable * @param bool $handheld * @param array $extraQuery - * * @return array */ public static function makeLoaderQuery( $modules, $lang, $skin, $user = null, @@ -1718,9 +1717,17 @@ MESSAGE; ) { $query = [ 'modules' => self::makePackedModulesString( $modules ), - 'lang' => $lang, - 'skin' => $skin, ]; + // Keep urls short by omitting query parameters that + // match the defaults assumed by ResourceLoaderContext. + // Note: This relies on the defaults either being insignificant or forever constant, + // as otherwise cached urls could change in meaning when the defaults change. + if ( $lang !== 'qqx' ) { + $query['lang'] = $lang; + } + if ( $skin !== 'fallback' ) { + $query['skin'] = $skin; + } if ( $debug === true ) { $query['debug'] = 'true'; } diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 1272b01448..f073f6ecf6 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -2715,14 +2715,14 @@ class OutputPageTest extends MediaWikiTestCase { [ [ 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ], "" ], // Multiple only=styles load [ [ [ 'test.baz', 'test.foo', 'test.bar' ], ResourceLoaderModule::TYPE_STYLES ], - '' + '' ], // Private embed (only=scripts) [ @@ -2747,14 +2747,14 @@ class OutputPageTest extends MediaWikiTestCase { // noscript group [ [ 'test.noscript', ResourceLoaderModule::TYPE_STYLES ], - '' + '' ], // Load two modules in separate groups [ [ [ 'test.group.foo', 'test.group.bar' ], ResourceLoaderModule::TYPE_COMBINED ], "" ], ]; @@ -2819,13 +2819,13 @@ class OutputPageTest extends MediaWikiTestCase { 'default logged-out' => [ 'exemptStyleModules' => [ 'site' => [ 'site.styles' ] ], '' . "\n" . - '', + '', ], 'default logged-in' => [ 'exemptStyleModules' => [ 'site' => [ 'site.styles' ], 'user' => [ 'user.styles' ] ], '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '', ], 'custom modules' => [ 'exemptStyleModules' => [ @@ -2833,10 +2833,10 @@ class OutputPageTest extends MediaWikiTestCase { 'user' => [ 'user.styles', 'example.user' ], ], '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '' . "\n" . + '', ], ]; // phpcs:enable diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 206160c7cf..03a3e24ad3 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -116,9 +116,9 @@ Deprecation message.' ] . '' . "\n" - . '' . "\n" + . '' . "\n" . '' . "\n" - . ''; + . ''; // phpcs:enable $expected = self::expandVariables( $expected ); @@ -136,7 +136,7 @@ Deprecation message.' ] // phpcs:disable Generic.Files.LineLength $expected = '' . "\n" - . ''; + . ''; // phpcs:enable $this->assertSame( $expected, (string)$client->getHeadHtml() ); @@ -153,7 +153,7 @@ Deprecation message.' ] // phpcs:disable Generic.Files.LineLength $expected = '' . "\n" - . ''; + . ''; // phpcs:enable $this->assertSame( $expected, (string)$client->getHeadHtml() ); @@ -170,7 +170,7 @@ Deprecation message.' ] // phpcs:disable Generic.Files.LineLength $expected = '' . "\n" - . ''; + . ''; // phpcs:enable $this->assertSame( $expected, (string)$client->getHeadHtml() ); @@ -228,50 +228,50 @@ Deprecation message.' ] 'modules' => [ 'test.scripts.raw' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, 'extra' => [], - 'output' => '', + 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.scripts.raw' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, 'extra' => [ 'sync' => '1' ], - 'output' => '', + 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.scripts.user' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, 'extra' => [], - 'output' => '', + 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.user' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, 'extra' => [], - 'output' => '', + 'output' => '', ], [ 'context' => [ 'debug' => 'true' ], 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, 'extra' => [], - 'output' => '' . "\n" - . '', + 'output' => '' . "\n" + . '', ], [ 'context' => [ 'debug' => 'false' ], 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ], 'only' => ResourceLoaderModule::TYPE_STYLES, 'extra' => [], - 'output' => '', + 'output' => '', ], [ 'context' => [], 'modules' => [ 'test.styles.noscript' ], 'only' => ResourceLoaderModule::TYPE_STYLES, 'extra' => [], - 'output' => '', + 'output' => '', ], [ 'context' => [], @@ -299,7 +299,7 @@ Deprecation message.' ] 'modules' => [ 'test', 'test.shouldembed' ], 'only' => ResourceLoaderModule::TYPE_COMBINED, 'extra' => [], - 'output' => '', + 'output' => '', ], [ 'context' => [], @@ -307,7 +307,7 @@ Deprecation message.' ] 'only' => ResourceLoaderModule::TYPE_STYLES, 'extra' => [], 'output' => - '' . "\n" + '' . "\n" . '' ], [ @@ -316,9 +316,9 @@ Deprecation message.' ] 'only' => ResourceLoaderModule::TYPE_STYLES, 'extra' => [], 'output' => - '' . "\n" + '' . "\n" . '' . "\n" - . '' + . '' ], ]; // phpcs:enable