Merge "Soft deprecate Title::getUserCaseDBKey()"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderStartUpModule.php
index 8140c2c..b5d31ef 100644 (file)
@@ -78,10 +78,11 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                $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' ),
@@ -126,7 +127,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgCommentCodePointLimit' => $oldCommentSchema ? null : CommentStore::COMMENT_CHARACTER_LIMIT,
                ];
 
-               Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars ] );
+               Hooks::run( 'ResourceLoaderGetConfigVars', [ &$vars, $skin ] );
 
                return $vars;
        }
@@ -404,16 +405,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        $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() ),
                ];
                $profilerStubs = [
                        '$CODE.profileExecuteStart();' => 'mw.loader.profiler.onExecuteStart( module );',
@@ -432,13 +426,11 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
 
                // Perform string replacements for startup.js
                $pairs = [
-                       '$VARS.wgLegacyJavaScriptGlobals' => json_encode(
-                               $this->getConfig()->get( 'LegacyJavaScriptGlobals' ),
-                               $jsonFlags
+                       '$VARS.wgLegacyJavaScriptGlobals' => ResourceLoader::encodeJsonForScript(
+                               $this->getConfig()->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 ) ),