resourceloader: Ensure 'user' loads after 'site' (asynchronously)
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index bf34c22..7875048 100644 (file)
@@ -1105,7 +1105,11 @@ MESSAGE;
                $name, $scripts, $styles, $messages, $templates
        ) {
                if ( is_string( $scripts ) ) {
-                       $scripts = new XmlJsCode( "function ( $, jQuery ) {\n{$scripts}\n}" );
+                       // Site and user module are a legacy scripts that run in the global scope (no closure).
+                       // Transportation as string instructs mw.loader.implement to use globalEval.
+                       if ( $name !== 'site' && $name !== 'user' ) {
+                               $scripts = new XmlJsCode( "function ( $, jQuery ) {\n{$scripts}\n}" );
+                       }
                } elseif ( !is_array( $scripts ) ) {
                        throw new MWException( 'Invalid scripts error. Array of URLs or string of code expected.' );
                }