Merge "Use PHP_OS rather than php_uname, which may be disabled"
[lhc/web/wiklou.git] / includes / OutputPage.php
index aa282a7..28d55e4 100644 (file)
@@ -1412,7 +1412,8 @@ class OutputPage extends ContextSource {
                if ( $overrideBaseUrl ) {
                        $helpUrl = $to;
                } else {
-                       $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$to";
+                       $toUrlencoded = wfUrlencode( str_replace( ' ', '_', $to ) );
+                       $helpUrl = "//www.mediawiki.org/wiki/Special:MyLanguage/$toUrlencoded";
                }
                $link = Html::rawElement(
                        'a',
@@ -2853,10 +2854,8 @@ class OutputPage extends ContextSource {
                                                        $resourceLoader->makeModuleResponse( $context, $grpModules )
                                                );
                                        } else {
-                                               $links['html'] .= Html::inlineScript(
-                                                       ResourceLoader::makeLoaderConditionalScript(
-                                                               $resourceLoader->makeModuleResponse( $context, $grpModules )
-                                                       )
+                                               $links['html'] .= ResourceLoader::makeInlineScript(
+                                                       $resourceLoader->makeModuleResponse( $context, $grpModules )
                                                );
                                        }
                                        $links['html'] .= "\n";
@@ -2895,22 +2894,18 @@ class OutputPage extends ContextSource {
                                        if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
                                                $link = Html::linkedStyle( $url );
                                        } elseif ( $loadCall ) {
-                                               $link = Html::inlineScript(
-                                                       ResourceLoader::makeLoaderConditionalScript(
-                                                               Xml::encodeJsCall( 'mw.loader.load', array( $url, 'text/javascript', true ) )
-                                                       )
+                                               $link = ResourceLoader::makeInlineScript(
+                                                       Xml::encodeJsCall( 'mw.loader.load', array( $url, 'text/javascript', true ) )
                                                );
                                        } else {
                                                $link = Html::linkedScript( $url );
-                                               if ( $context->getOnly() === 'scripts' && !$context->getRaw() && !$isRaw ) {
-                                                       // Wrap only=script requests in a conditional as browsers not supported
-                                                       // by the startup module would unconditionally execute this module.
-                                                       // Otherwise users will get "ReferenceError: mw is undefined" or
-                                                       // "jQuery is undefined" from e.g. a "site" module.
-                                                       $link = Html::inlineScript(
-                                                               ResourceLoader::makeLoaderConditionalScript(
-                                                                       Xml::encodeJsCall( 'document.write', array( $link ) )
-                                                               )
+                                               if ( !$context->getRaw() && !$isRaw ) {
+                                                       // Wrap only=script / only=combined requests in a conditional as
+                                                       // browsers not supported by the startup module would unconditionally
+                                                       // execute this module. Otherwise users will get "ReferenceError: mw is
+                                                       // undefined" or "jQuery is undefined" from e.g. a "site" module.
+                                                       $link = ResourceLoader::makeInlineScript(
+                                                               Xml::encodeJsCall( 'document.write', array( $link ) )
                                                        );
                                                }
 
@@ -2954,10 +2949,8 @@ class OutputPage extends ContextSource {
                }
 
                if ( count( $states ) ) {
-                       $html = Html::inlineScript(
-                               ResourceLoader::makeLoaderConditionalScript(
-                                       ResourceLoader::makeLoaderStateScript( $states )
-                               )
+                       $html = ResourceLoader::makeInlineScript(
+                               ResourceLoader::makeLoaderStateScript( $states )
                        ) . "\n" . $html;
                }
 
@@ -2976,10 +2969,8 @@ class OutputPage extends ContextSource {
                $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true );
 
                // Load config before anything else
-               $links[] = Html::inlineScript(
-                       ResourceLoader::makeLoaderConditionalScript(
-                               ResourceLoader::makeConfigSetScript( $this->getJSVars() )
-                       )
+               $links[] = ResourceLoader::makeInlineScript(
+                       ResourceLoader::makeConfigSetScript( $this->getJSVars() )
                );
 
                // Load embeddable private modules before any loader links
@@ -3003,10 +2994,8 @@ class OutputPage extends ContextSource {
                // Only load modules that have marked themselves for loading at the top
                $modules = $this->getModules( true, 'top' );
                if ( $modules ) {
-                       $links[] = Html::inlineScript(
-                               ResourceLoader::makeLoaderConditionalScript(
-                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules ) )
-                               )
+                       $links[] = ResourceLoader::makeInlineScript(
+                               Xml::encodeJsCall( 'mw.loader.load', array( $modules ) )
                        );
                }
 
@@ -3046,10 +3035,8 @@ class OutputPage extends ContextSource {
                // Only load modules that have marked themselves for loading at the bottom
                $modules = $this->getModules( true, 'bottom' );
                if ( $modules ) {
-                       $links[] = Html::inlineScript(
-                               ResourceLoader::makeLoaderConditionalScript(
-                                       Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
-                               )
+                       $links[] = ResourceLoader::makeInlineScript(
+                               Xml::encodeJsCall( 'mw.loader.load', array( $modules, null, true ) )
                        );
                }
 
@@ -3105,7 +3092,7 @@ class OutputPage extends ContextSource {
                // This also enforces $.isReady to be true at </body> which fixes the
                // mw.loader bug in Firefox with using document.write between </body>
                // and the DOMContentReady event (bug 47457).
-               $html = Html::inlineScript( 'window.jQuery && jQuery.ready();' );
+               $html = Html::inlineScript( 'if(window.jQuery)jQuery.ready();' );
 
                if ( !$this->getConfig()->get( 'ResourceLoaderExperimentalAsyncLoading' ) ) {
                        $html .= $this->getScriptsForBottomQueue( false );
@@ -3287,6 +3274,10 @@ class OutputPage extends ContextSource {
                if ( !$this->getTitle()->isJsSubpage() && !$this->getTitle()->isCssSubpage() ) {
                        return false;
                }
+               if ( !$this->getTitle()->isSubpageOf( $this->getUser()->getUserPage() ) ) {
+                       // Don't execute another user's CSS or JS on preview (T85855)
+                       return false;
+               }
 
                return !count( $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getUser() ) );
        }