<?php
/**
- * Module for ResourceLoader initialization.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* @author Roan Kattouw
*/
+/**
+ * Module for ResourceLoader initialization.
+ *
+ * See also <https://www.mediawiki.org/wiki/ResourceLoader/Features#Startup_Module>
+ *
+ * The startup module, as being called only from ResourceLoaderClientHtml, has
+ * the ability to vary based extra query parameters, in addition to those
+ * from ResourceLoaderContext:
+ *
+ * - target: Only register modules in the client allowed within this target.
+ * Default: "desktop".
+ * See also: OutputPage::setTarget(), ResourceLoaderModule::getTargets().
+ */
class ResourceLoaderStartUpModule extends ResourceLoaderModule {
// Cache for getConfigSettings() as it's called by multiple methods
}
$illegalFileChars = $conf->get( 'IllegalFileChars' );
+ $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
// Build list of variables
$vars = [
'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ),
'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ),
'wgEnableUploads' => $conf->get( 'EnableUploads' ),
+ 'wgCommentByteLimit' => $oldCommentSchema ? 255 : null,
+ 'wgCommentCodePointLimit' => $oldCommentSchema ? null : CommentStore::COMMENT_CHARACTER_LIMIT,
];
Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars ] );
return true;
}
+ /**
+ * @param ResourceLoaderContext $context
+ * @return array
+ */
+ public function getPreloadLinks( ResourceLoaderContext $context ) {
+ $url = self::getStartupModulesUrl( $context );
+ return [
+ $url => [ 'as' => 'script' ]
+ ];
+ }
+
/**
* Base modules required for the base environment of ResourceLoader
*
}, [
'$VARS.wgLegacyJavaScriptGlobals' => $this->getConfig()->get( 'LegacyJavaScriptGlobals' ),
'$VARS.configuration' => $this->getConfigSettings( $context ),
+ // This url may be preloaded. See getPreloadLinks().
'$VARS.baseModulesUri' => self::getStartupModulesUrl( $context ),
] );
$pairs['$CODE.registrations()'] = str_replace(