/** @var array */
protected $mModules = [];
- /** @var array */
- protected $mModuleScripts = [];
-
/** @var array */
protected $mModuleStyles = [];
}
/**
- * Get the list of script-only modules to load on this page.
- *
- * @param bool $filter
- * @param string|null $position Unused
- * @return array Array of module names
- */
- public function getModuleScripts( $filter = false, $position = null ) {
- return $this->getModules( $filter, null, 'mModuleScripts',
- ResourceLoaderModule::TYPE_SCRIPTS
- );
- }
-
- /**
- * Load the scripts of one or more ResourceLoader modules, on this page.
- *
- * This method exists purely to provide the legacy behaviour of loading
- * a module's scripts in the global scope, and without dependency resolution.
- * See <https://phabricator.wikimedia.org/T188689>.
- *
- * @deprecated since 1.31 Use addModules() instead.
- * @param string|array $modules Module name (string) or array of module names
+ * @deprecated since 1.33 Use getModules() instead.
+ * @return array
*/
- public function addModuleScripts( $modules ) {
- $this->mModuleScripts = array_merge( $this->mModuleScripts, (array)$modules );
+ public function getModuleScripts() {
+ wfDeprecated( __METHOD__, '1.33' );
+ return [];
}
/**
$this->mNoGallery = $parserOutput->getNoGallery();
$this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
$this->addModules( $parserOutput->getModules() );
- $this->addModuleScripts( $parserOutput->getModuleScripts() );
$this->addModuleStyles( $parserOutput->getModuleStyles() );
$this->addJsConfigVars( $parserOutput->getJsConfigVars() );
$this->mPreventClickjacking = $this->mPreventClickjacking
$this->addParserOutputText( $parserOutput, $poOptions );
$this->addModules( $parserOutput->getModules() );
- $this->addModuleScripts( $parserOutput->getModuleScripts() );
$this->addModuleStyles( $parserOutput->getModuleStyles() );
$this->addJsConfigVars( $parserOutput->getJsConfigVars() );
$rlClient->setConfig( $this->getJSVars() );
$rlClient->setModules( $this->getModules( /*filter*/ true ) );
$rlClient->setModuleStyles( $moduleStyles );
- $rlClient->setModuleScripts( $this->getModuleScripts( /*filter*/ true ) );
$rlClient->setExemptStates( $exemptStates );
$this->rlClient = $rlClient;
}
}
if ( isset( $prop['modules'] ) ) {
$retval['modules'] = array_values( array_unique( $p_output->getModules() ) );
- $retval['modulescripts'] = array_values( array_unique( $p_output->getModuleScripts() ) );
+ // Deprecated since 1.32 (T188689)
+ $retval['modulescripts'] = [];
$retval['modulestyles'] = array_values( array_unique( $p_output->getModuleStyles() ) );
}
if ( isset( $prop['jsconfigvars'] ) ) {
'html' => $out->getHTML(),
'modules' => array_values( array_unique( array_merge(
$out->getModules(),
- $out->getModuleScripts(),
$out->getModuleStyles()
) ) ),
'continue' => $this->getResult()->getResultData( 'continue' ),
if ( isset( $prop['modules'] ) ) {
if ( $skin ) {
$result_array['modules'] = $outputPage->getModules();
- $result_array['modulescripts'] = $outputPage->getModuleScripts();
+ // Deprecated since 1.32 (T188689)
+ $result_array['modulescripts'] = [];
$result_array['modulestyles'] = $outputPage->getModuleStyles();
} else {
$result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
- $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
+ // Deprecated since 1.32 (T188689)
+ $result_array['modulescripts'] = [];
$result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
}
}
*/
public $mModules = [];
- /**
- * @var array $mModuleScripts Modules of which only the JS will be loaded by ResourceLoader.
- */
- public $mModuleScripts = [];
-
/**
* @var array $mModuleStyles Modules of which only the CSSS will be loaded by ResourceLoader.
*/
}
public function getModuleScripts() {
- return $this->mModuleScripts;
+ wfDeprecated( __METHOD__, '1.33' );
+ return [];
}
public function getModuleStyles() {
$this->mModules = array_merge( $this->mModules, (array)$modules );
}
- /**
- * @deprecated since 1.31 Use addModules() instead.
- * @see OutputPage::addModuleScripts
- */
- public function addModuleScripts( $modules ) {
- $this->mModuleScripts = array_merge( $this->mModuleScripts, (array)$modules );
- }
-
/**
* @see OutputPage::addModuleStyles
*/
*/
public function addOutputPageMetadata( OutputPage $out ) {
$this->addModules( $out->getModules() );
- $this->addModuleScripts( $out->getModuleScripts() );
$this->addModuleStyles( $out->getModuleStyles() );
$this->addJsConfigVars( $out->getJsConfigVars() );
// HTML and HTTP
$this->mHeadItems = self::mergeMixedList( $this->mHeadItems, $source->getHeadItems() );
$this->mModules = self::mergeList( $this->mModules, $source->getModules() );
- $this->mModuleScripts = self::mergeList( $this->mModuleScripts, $source->getModuleScripts() );
$this->mModuleStyles = self::mergeList( $this->mModuleStyles, $source->getModuleStyles() );
$this->mJsConfigVars = self::mergeMap( $this->mJsConfigVars, $source->getJsConfigVars() );
$this->mMaxAdaptiveExpiry = min( $this->mMaxAdaptiveExpiry, $source->mMaxAdaptiveExpiry );
/** @var array */
private $moduleStyles = [];
- /** @var array */
- private $moduleScripts = [];
-
/** @var array */
private $exemptStates = [];
$this->moduleStyles = $modules;
}
- /**
- * Ensure the scripts of one or more modules are loaded.
- *
- * @deprecated since 1.28
- * @param array $modules Array of module names
- */
- public function setModuleScripts( array $modules ) {
- $this->moduleScripts = $modules;
- }
-
/**
* Set state of special modules that are handled by the caller manually.
*
],
'general' => [],
'styles' => [],
- 'scripts' => [],
// Embedding for private modules
'embed' => [
'styles' => [],
}
}
- foreach ( $this->moduleScripts as $name ) {
- $module = $rl->getModule( $name );
- if ( !$module ) {
- continue;
- }
-
- $group = $module->getGroup();
- $context = $this->getContext( $group, ResourceLoaderModule::TYPE_SCRIPTS );
- if ( $module->isKnownEmpty( $context ) ) {
- // Avoid needless request for empty module
- $data['states'][$name] = 'ready';
- } else {
- // Load from load.php?only=scripts via <script src></script>
- $data['scripts'][] = $name;
-
- // Avoid duplicate request from mw.loader
- $data['states'][$name] = 'loading';
- }
- }
-
return $data;
}
);
}
- // Inline RLQ: Load only=scripts
- if ( $data['scripts'] ) {
- $chunks[] = $this->getLoad(
- $data['scripts'],
- ResourceLoaderModule::TYPE_SCRIPTS,
- $nonce
- );
- }
-
// External stylesheets (only=styles)
if ( $data['styles'] ) {
$chunks[] = $this->getLoad(
}
if ( response.parse.modules ) {
mw.loader.load( response.parse.modules.concat(
- response.parse.modulescripts,
response.parse.modulestyles
) );
}
// @todo Make sure to test the following in addParserOutputMetadata() as well when we add tests
// for them:
// * addModules()
- // * addModuleScripts()
// * addModuleStyles()
// * addJsConfigVars()
// * enableOOUI()
function ( $parser ) {
$output = $parser->getOutput();
$output->addModules( [ 'foo', 'bar' ] );
- $output->addModuleScripts( [ 'baz', 'quuz' ] );
$output->addModuleStyles( [ 'aaa', 'zzz' ] );
$output->addJsConfigVars( [ 'x' => 'y', 'z' => -3 ] );
}
] );
$this->assertSame( [ 'foo', 'bar' ], $res[0]['parse']['modules'] );
- $this->assertSame( [ 'baz', 'quuz' ], $res[0]['parse']['modulescripts'] );
+ $this->assertSame( [], $res[0]['parse']['modulescripts'] );
$this->assertSame( [ 'aaa', 'zzz' ], $res[0]['parse']['modulestyles'] );
$this->assertSame( [ 'x' => 'y', 'z' => -3 ], $res[0]['parse']['jsconfigvars'] );
$this->assertSame( '{"x":"y","z":-3}', $res[0]['parse']['encodedjsconfigvars'] );
$a->addHeadItem( '<foo1>' );
$a->addHeadItem( '<bar1>', 'bar' );
$a->addModules( 'test-module-a' );
- $a->addModuleScripts( 'test-module-script-a' );
$a->addModuleStyles( 'test-module-styles-a' );
$b->addJsConfigVars( 'test-config-var-a', 'a' );
$b->addHeadItem( '<foo2>' );
$b->addHeadItem( '<bar2>', 'bar' );
$b->addModules( 'test-module-b' );
- $b->addModuleScripts( 'test-module-script-b' );
$b->addModuleStyles( 'test-module-styles-b' );
$b->addJsConfigVars( 'test-config-var-b', 'b' );
$b->addJsConfigVars( 'test-config-var-a', 'X' );
'test-module-a',
'test-module-b',
],
- 'getModuleScripts' => [
- 'test-module-script-a',
- 'test-module-script-b',
- ],
'getModuleStyles' => [
'test-module-styles-a',
'test-module-styles-b',
* @covers ResourceLoaderClientHtml::__construct
* @covers ResourceLoaderClientHtml::setModules
* @covers ResourceLoaderClientHtml::setModuleStyles
- * @covers ResourceLoaderClientHtml::setModuleScripts
* @covers ResourceLoaderClientHtml::getData
* @covers ResourceLoaderClientHtml::getContext
*/
'test.styles.deprecated',
'test.unregistered.styles',
] );
- $client->setModuleScripts( [
- 'test.scripts',
- 'test.scripts.user',
- 'test.scripts.user.empty',
- 'test.scripts.shouldembed',
- 'test.unregistered.scripts',
- ] );
$expected = [
'states' => [
'test.styles.private' => 'ready',
'test.styles.shouldembed' => 'ready',
'test.styles.deprecated' => 'ready',
- 'test.scripts' => 'loading',
- 'test.scripts.user' => 'loading',
- 'test.scripts.user.empty' => 'ready',
- 'test.scripts.shouldembed' => 'loading',
],
'general' => [
'test',
'test.styles.pure',
'test.styles.deprecated',
],
- 'scripts' => [
- 'test.scripts',
- 'test.scripts.user',
- 'test.scripts.shouldembed',
- ],
'embed' => [
'styles' => [ 'test.styles.private', 'test.styles.shouldembed' ],
'general' => [
'test.styles.private',
'test.styles.deprecated',
] );
- $client->setModuleScripts( [
- 'test.scripts',
- ] );
$client->setExemptStates( [
'test.exempt' => 'ready',
] );
$expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n"
. '<script>(window.RLQ=window.RLQ||[]).push(function(){'
. 'mw.config.set({"key":"value"});'
- . 'mw.loader.state({"test.exempt":"ready","test.private":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.styles.deprecated":"ready","test.scripts":"loading"});'
+ . 'mw.loader.state({"test.exempt":"ready","test.private":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.styles.deprecated":"ready"});'
. 'mw.loader.implement("test.private@{blankVer}",null,{"css":[]});'
. 'RLPAGEMODULES=["test"];mw.loader.load(RLPAGEMODULES);'
- . 'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts\u0026only=scripts\u0026skin=fallback");'
. '});</script>' . "\n"
. '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.deprecated%2Cpure&only=styles&skin=fallback"/>' . "\n"
. '<style>.private{}</style>' . "\n"
$client->setModuleStyles( [
'test.styles.deprecated',
] );
- $client->setModuleScripts( [
- 'test.scripts',
- ] );
// phpcs:disable Generic.Files.LineLength
$expected = '<script>(window.RLQ=window.RLQ||[]).push(function(){'
. 'mw.log.warn("This page is using the deprecated ResourceLoader module \"test.styles.deprecated\".\nDeprecation message.");'