/**
* @param ResourceLoaderContext $context
- * @param aray $target [optional] Custom 'target' parameter for the startup module
+ * @param string|null $target [optional] Custom 'target' parameter for the startup module
*/
public function __construct( ResourceLoaderContext $context, $target = null ) {
$this->context = $context;
'states' => [
// moduleName => state
],
- 'general' => [
- // position => [ moduleName ]
- 'top' => [],
- 'bottom' => [],
- ],
+ 'general' => [],
'styles' => [
// moduleName
],
- 'scripts' => [
- // position => [ moduleName ]
- 'top' => [],
- 'bottom' => [],
- ],
+ 'scripts' => [],
// Embedding for private modules
'embed' => [
'styles' => [],
- 'general' => [
- 'top' => [],
- 'bottom' => [],
- ],
+ 'general' => [],
],
];
}
$group = $module->getGroup();
- $position = $module->getPosition();
if ( $group === 'private' ) {
// Embed via mw.loader.implement per T36907.
- $data['embed']['general'][$position][] = $name;
+ $data['embed']['general'][] = $name;
// Avoid duplicate request from mw.loader
$data['states'][$name] = 'loading';
} else {
// Load via mw.loader.load()
- $data['general'][$position][] = $name;
+ $data['general'][] = $name;
}
}
}
$group = $module->getGroup();
- $position = $module->getPosition();
$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'][$position][] = $name;
+ $data['scripts'][] = $name;
// Avoid duplicate request from mw.loader
$data['states'][$name] = 'loading';
}
// Inline RLQ: Embedded modules
- if ( $data['embed']['general']['top'] ) {
+ if ( $data['embed']['general'] ) {
$chunks[] = $this->getLoad(
- $data['embed']['general']['top'],
+ $data['embed']['general'],
ResourceLoaderModule::TYPE_COMBINED
);
}
// Inline RLQ: Load general modules
- if ( $data['general']['top'] ) {
+ if ( $data['general'] ) {
$chunks[] = ResourceLoader::makeInlineScript(
- Xml::encodeJsCall( 'mw.loader.load', [ $data['general']['top'] ] )
+ Xml::encodeJsCall( 'mw.loader.load', [ $data['general'] ] )
);
}
// Inline RLQ: Load only=scripts
- if ( $data['scripts']['top'] ) {
+ if ( $data['scripts'] ) {
$chunks[] = $this->getLoad(
- $data['scripts']['top'],
+ $data['scripts'],
ResourceLoaderModule::TYPE_SCRIPTS
);
}
* @return string|WrappedStringList HTML
*/
public function getBodyHtml() {
- $data = $this->getData();
- $chunks = [];
-
- // Inline RLQ: Embedded modules
- if ( $data['embed']['general']['bottom'] ) {
- $chunks[] = $this->getLoad(
- $data['embed']['general']['bottom'],
- ResourceLoaderModule::TYPE_COMBINED
- );
- }
-
- // Inline RLQ: Load only=scripts
- if ( $data['scripts']['bottom'] ) {
- $chunks[] = $this->getLoad(
- $data['scripts']['bottom'],
- ResourceLoaderModule::TYPE_SCRIPTS
- );
- }
-
- // Inline RLQ: Load general modules
- if ( $data['general']['bottom'] ) {
- $chunks[] = ResourceLoader::makeInlineScript(
- Xml::encodeJsCall( 'mw.loader.load', [ $data['general']['bottom'] ] )
- );
- }
-
- return WrappedStringList::join( "\n", $chunks );
+ return '';
}
private function getContext( $group, $type ) {
$rl = $mainContext->getResourceLoader();
$chunks = [];
+ // Sort module names so requests are more uniform
+ sort( $modules );
+
if ( $mainContext->getDebug() && count( $modules ) > 1 ) {
+
$chunks = [];
// Recursively call us for every item
foreach ( $modules as $name ) {
return new WrappedStringList( "\n", $chunks );
}
- // Sort module names so requests are more uniform
- sort( $modules );
// Create keyed-by-source and then keyed-by-group list of module objects from modules list
$sortedModules = [];
foreach ( $modules as $name ) {
// Special handling for the user group; because users might change their stuff
// on-wiki like user pages, or user preferences; we need to find the highest
// timestamp of these user-changeable modules so we can ensure cache misses on change
- // This should NOT be done for the site group (bug 27564) because anons get that too
+ // This should NOT be done for the site group (T29564) because anons get that too
// and we shouldn't be putting timestamps in CDN-cached HTML
if ( $group === 'user' ) {
// Must setModules() before makeVersionQuery()