From 24e54d699985ee7858b919c114c77ff26dec3c6e Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 13 Jun 2019 20:13:35 +0100 Subject: [PATCH] resourceloader: Migrate use of 'raw' modules to 'raw' requests The ResourceLoaderModule::isRaw() feature and the ability to magically switch a regular load.php request into raw mode is being removed soon. Instead, specify raw=1 in the request url where that behaviour is needed. Bug: T201483 Change-Id: Ie4564ec8e26ad53f2de1a43330d18a35b0498a63 --- includes/OutputPage.php | 2 +- .../ResourceLoaderClientHtml.php | 2 +- includes/specials/SpecialJavaScriptTest.php | 2 +- .../ResourceLoaderClientHtmlTest.php | 23 +++++++++---------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 5833677b97..fba73e98b8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3222,7 +3222,7 @@ class OutputPage extends ContextSource { ), [ 'html5shiv' ], ResourceLoaderModule::TYPE_SCRIPTS, - [ 'sync' => true ], + [ 'raw' => '1', 'sync' => '1' ], $this->getCSPNonce() ) . ''; diff --git a/includes/resourceloader/ResourceLoaderClientHtml.php b/includes/resourceloader/ResourceLoaderClientHtml.php index 6061fb518e..7f2f85fe14 100644 --- a/includes/resourceloader/ResourceLoaderClientHtml.php +++ b/includes/resourceloader/ResourceLoaderClientHtml.php @@ -303,7 +303,7 @@ JAVASCRIPT; // Async scripts. Once the startup is loaded, inline RLQ scripts will run. // Pass-through a custom 'target' from OutputPage (T143066). - $startupQuery = []; + $startupQuery = [ 'raw' => '1' ]; foreach ( [ 'target', 'safemode' ] as $param ) { if ( $this->options[$param] !== null ) { $startupQuery[$param] = (string)$this->options[$param]; diff --git a/includes/specials/SpecialJavaScriptTest.php b/includes/specials/SpecialJavaScriptTest.php index c984af8dec..3e9676c64e 100644 --- a/includes/specials/SpecialJavaScriptTest.php +++ b/includes/specials/SpecialJavaScriptTest.php @@ -174,7 +174,7 @@ JAVASCRIPT // load before qunit/export. $scripts = $out->makeResourceLoaderLink( 'jquery.qunit', ResourceLoaderModule::TYPE_SCRIPTS, - [ 'raw' => true, 'sync' => true ] + [ 'raw' => '1', 'sync' => '1' ] ); $head = implode( "\n", [ $styles, $scripts ] ); diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 03a3e24ad3..408a0a24cc 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -118,7 +118,7 @@ Deprecation message.' ] . '});' . "\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() ); @@ -224,18 +224,18 @@ Deprecation message.' ] ], [ 'context' => [], - // Eg. startup module - 'modules' => [ 'test.scripts.raw' ], + 'modules' => [ 'test.scripts' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, - 'extra' => [], - 'output' => '', + // Eg. startup module + 'extra' => [ 'raw' => '1' ], + 'output' => '', ], [ 'context' => [], - 'modules' => [ 'test.scripts.raw' ], + 'modules' => [ 'test.scripts' ], 'only' => ResourceLoaderModule::TYPE_SCRIPTS, - 'extra' => [ 'sync' => '1' ], - 'output' => '', + 'extra' => [ 'raw' => '1', 'sync' => '1' ], + 'output' => '', ], [ 'context' => [], @@ -418,7 +418,6 @@ Deprecation message.' ] 'test.scripts' => [], 'test.scripts.user' => [ 'group' => 'user' ], 'test.scripts.user.empty' => [ 'group' => 'user', 'isKnownEmpty' => true ], - 'test.scripts.raw' => [ 'isRaw' => true ], 'test.scripts.shouldembed' => [ 'shouldEmbed' => true ], 'test.ordering.a' => [ 'shouldEmbed' => false ], -- 2.20.1