resourceloader: Migrate use of 'raw' modules to 'raw' requests
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 13 Jun 2019 19:13:35 +0000 (20:13 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 14 Jun 2019 16:57:22 +0000 (17:57 +0100)
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
includes/resourceloader/ResourceLoaderClientHtml.php
includes/specials/SpecialJavaScriptTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php

index 5833677..fba73e9 100644 (file)
@@ -3222,7 +3222,7 @@ class OutputPage extends ContextSource {
                                ),
                                [ 'html5shiv' ],
                                ResourceLoaderModule::TYPE_SCRIPTS,
-                               [ 'sync' => true ],
+                               [ 'raw' => '1', 'sync' => '1' ],
                                $this->getCSPNonce()
                        ) .
                        '<![endif]-->';
index 6061fb5..7f2f85f 100644 (file)
@@ -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];
index c984af8..3e9676c 100644 (file)
@@ -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 ] );
index 03a3e24..408a0a2 100644 (file)
@@ -118,7 +118,7 @@ Deprecation message.' ]
                        . '});</script>' . "\n"
                        . '<link rel="stylesheet" href="/w/load.php?lang=nl&amp;modules=test.styles.deprecated%2Cpure&amp;only=styles"/>' . "\n"
                        . '<style>.private{}</style>' . "\n"
-                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts"></script>';
+                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;raw=1"></script>';
                // phpcs:enable
                $expected = self::expandVariables( $expected );
 
@@ -136,7 +136,7 @@ Deprecation message.' ]
 
                // phpcs:disable Generic.Files.LineLength
                $expected = '<script>document.documentElement.className=document.documentElement.className.replace(/(^|\s)client-nojs(\s|$)/,"$1client-js$2");</script>' . "\n"
-                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;target=example"></script>';
+                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;target=example"></script>';
                // phpcs:enable
 
                $this->assertSame( $expected, (string)$client->getHeadHtml() );
@@ -153,7 +153,7 @@ Deprecation message.' ]
 
                // phpcs:disable Generic.Files.LineLength
                $expected = '<script>document.documentElement.className=document.documentElement.className.replace(/(^|\s)client-nojs(\s|$)/,"$1client-js$2");</script>' . "\n"
-                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;safemode=1"></script>';
+                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;raw=1&amp;safemode=1"></script>';
                // phpcs:enable
 
                $this->assertSame( $expected, (string)$client->getHeadHtml() );
@@ -170,7 +170,7 @@ Deprecation message.' ]
 
                // phpcs:disable Generic.Files.LineLength
                $expected = '<script>document.documentElement.className=document.documentElement.className.replace(/(^|\s)client-nojs(\s|$)/,"$1client-js$2");</script>' . "\n"
-                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts"></script>';
+                       . '<script async="" src="/w/load.php?lang=nl&amp;modules=startup&amp;only=scripts&amp;raw=1"></script>';
                // 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' => '<script async="" src="/w/load.php?lang=nl&amp;modules=test.scripts.raw&amp;only=scripts"></script>',
+                               // Eg. startup module
+                               'extra' => [ 'raw' => '1' ],
+                               'output' => '<script async="" src="/w/load.php?lang=nl&amp;modules=test.scripts&amp;only=scripts&amp;raw=1"></script>',
                        ],
                        [
                                'context' => [],
-                               'modules' => [ 'test.scripts.raw' ],
+                               'modules' => [ 'test.scripts' ],
                                'only' => ResourceLoaderModule::TYPE_SCRIPTS,
-                               'extra' => [ 'sync' => '1' ],
-                               'output' => '<script src="/w/load.php?lang=nl&amp;modules=test.scripts.raw&amp;only=scripts&amp;sync=1"></script>',
+                               'extra' => [ 'raw' => '1', 'sync' => '1' ],
+                               'output' => '<script src="/w/load.php?lang=nl&amp;modules=test.scripts&amp;only=scripts&amp;raw=1&amp;sync=1"></script>',
                        ],
                        [
                                '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 ],