}
$illegalFileChars = $conf->get( 'IllegalFileChars' );
- $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD;
// Build list of variables
+ $skin = $context->getSkin();
$vars = [
'wgLoadScript' => wfScript( 'load' ),
'debug' => $context->getDebug(),
- 'skin' => $context->getSkin(),
+ 'skin' => $skin,
'stylepath' => $conf->get( 'StylePath' ),
'wgUrlProtocols' => wfUrlProtocols(),
'wgArticlePath' => $conf->get( 'ArticlePath' ),
'wgSiteName' => $conf->get( 'Sitename' ),
'wgDBname' => $conf->get( 'DBname' ),
'wgExtraSignatureNamespaces' => $conf->get( 'ExtraSignatureNamespaces' ),
- 'wgAvailableSkins' => Skin::getSkinNames(),
'wgExtensionAssetsPath' => $conf->get( 'ExtensionAssetsPath' ),
// MediaWiki sets cookies to have this prefix by default
'wgCookiePrefix' => $conf->get( 'CookiePrefix' ),
'wgCookieDomain' => $conf->get( 'CookieDomain' ),
'wgCookiePath' => $conf->get( 'CookiePath' ),
'wgCookieExpiration' => $conf->get( 'CookieExpiration' ),
- 'wgResourceLoaderMaxQueryLength' => $conf->get( 'ResourceLoaderMaxQueryLength' ),
'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ),
'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ),
'wgForeignUploadTargets' => $conf->get( 'ForeignUploadTargets' ),
'wgEnableUploads' => $conf->get( 'EnableUploads' ),
- 'wgCommentByteLimit' => $oldCommentSchema ? 255 : null,
- 'wgCommentCodePointLimit' => $oldCommentSchema ? null : CommentStore::COMMENT_CHARACTER_LIMIT,
+ 'wgCommentByteLimit' => null,
+ 'wgCommentCodePointLimit' => CommentStore::COMMENT_CHARACTER_LIMIT,
];
- Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars ] );
+ Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars, $skin ] );
return $vars;
}
*/
public function getScript( ResourceLoaderContext $context ) {
global $IP;
+ $conf = $this->getConfig();
+
if ( $context->getOnly() !== 'scripts' ) {
return '/* Requires only=script */';
}
if ( $context->getDebug() ) {
$mwLoaderCode .= file_get_contents( "$IP/resources/src/startup/mediawiki.log.js" );
}
- if ( $this->getConfig()->get( 'ResourceLoaderEnableJSProfiler' ) ) {
+ if ( $conf->get( 'ResourceLoaderEnableJSProfiler' ) ) {
$mwLoaderCode .= file_get_contents( "$IP/resources/src/startup/profiler.js" );
}
- // Keep output as small as possible by disabling needless escapes that PHP uses by default.
- // This is not HTML output, only used in a JS response.
- $jsonFlags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
- if ( ResourceLoader::inDebugMode() ) {
- $jsonFlags |= JSON_PRETTY_PRINT;
- }
-
// Perform replacements for mediawiki.js
$mwLoaderPairs = [
- '$VARS.baseModules' => json_encode( $this->getBaseModules(), $jsonFlags ),
+ '$VARS.baseModules' => ResourceLoader::encodeJsonForScript( $this->getBaseModules() ),
+ '$VARS.maxQueryLength' => ResourceLoader::encodeJsonForScript(
+ $conf->get( 'ResourceLoaderMaxQueryLength' )
+ ),
];
$profilerStubs = [
'$CODE.profileExecuteStart();' => 'mw.loader.profiler.onExecuteStart( module );',
'$CODE.profileScriptStart();' => 'mw.loader.profiler.onScriptStart( module );',
'$CODE.profileScriptEnd();' => 'mw.loader.profiler.onScriptEnd( module );',
];
- if ( $this->getConfig()->get( 'ResourceLoaderEnableJSProfiler' ) ) {
+ if ( $conf->get( 'ResourceLoaderEnableJSProfiler' ) ) {
// When profiling is enabled, insert the calls.
$mwLoaderPairs += $profilerStubs;
} else {
// Perform string replacements for startup.js
$pairs = [
- '$VARS.wgLegacyJavaScriptGlobals' => json_encode(
- $this->getConfig()->get( 'LegacyJavaScriptGlobals' ),
- $jsonFlags
+ '$VARS.wgLegacyJavaScriptGlobals' => ResourceLoader::encodeJsonForScript(
+ $conf->get( 'LegacyJavaScriptGlobals' )
),
- '$VARS.configuration' => json_encode(
- $this->getConfigSettings( $context ),
- $jsonFlags
+ '$VARS.configuration' => ResourceLoader::encodeJsonForScript(
+ $this->getConfigSettings( $context )
),
// Raw JavaScript code (not JSON)
'$CODE.registrations();' => trim( $this->getModuleRegistrations( $context ) ),