r72010 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72009‎ | r72010 | r72011 >
Date:04:05, 31 August 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Fix all kinds of breakage. Debug mode is still broken because jquery tries to register itself before mediaWiki is available (but mediaWiki needs jquery... chicken and egg)
* Apparently variables have to be explicitly declared when using window. style. Fix the instances that casual runs of Firebug turned up, there might be more
* Remove {"0": "debug"} entry from config
* Add FIXME about variable name shading
* Register raw-loaded modules as ready so they aren't rerequested
* Put the mediaWiki.register() call in the right place
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoader.php (modified) (history)
  • /branches/resourceloader/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/skins/common/wikibits.js
@@ -3,6 +3,9 @@
44 window.clientPC = navigator.userAgent.toLowerCase(); // Get client info
55 window.is_gecko = /gecko/.test( clientPC ) &&
66 !/khtml|spoofer|netscape\/7\.0/.test(clientPC);
 7+
 8+window.is_safari = window.is_safari_win = window.webkit_version =
 9+ window.is_chrome = window.is_chrome_mac = false;
710 window.webkit_match = clientPC.match(/applewebkit\/(\d+)/);
811 if (webkit_match) {
912 window.is_safari = clientPC.indexOf('applewebkit') != -1 &&
@@ -15,12 +18,16 @@
1619 clientPC.indexOf('spoofer') === -1;
1720 window.is_chrome_mac = is_chrome && clientPC.indexOf('mac') !== -1
1821 }
 22+
1923 // For accesskeys; note that FF3+ is included here!
2024 window.is_ff2 = /firefox\/[2-9]|minefield\/3/.test( clientPC );
2125 window.ff2_bugs = /firefox\/2/.test( clientPC );
2226 // These aren't used here, but some custom scripts rely on them
2327 window.is_ff2_win = is_ff2 && clientPC.indexOf('windows') != -1;
2428 window.is_ff2_x11 = is_ff2 && clientPC.indexOf('x11') != -1;
 29+
 30+window.is_opera = window.is_opera_preseven = window.is_opera_95 =
 31+ window.opera6_bugs = window.opera7_bugs = window.opera95_bugs = false;
2532 if (clientPC.indexOf('opera') != -1) {
2633 window.is_opera = true;
2734 window.is_opera_preseven = window.opera && !document.childNodes;
Index: branches/resourceloader/phase3/includes/ResourceLoader.php
@@ -256,19 +256,23 @@
257257 $scripts .= $module->getScript( $parameters['lang'], $parameters['skin'], $parameters['debug'] );
258258 // Special meta-information for the 'mediawiki' module
259259 if ( $name === 'mediawiki' && $parameters['only'] === 'scripts' ) {
260 - $config = array( 'server' => $server, 'debug', 'debug' => $parameters['debug'] );
 260+ $config = array( 'server' => $server, 'debug' => $parameters['debug'] );
261261 $scripts .= "mediaWiki.config.set( " . FormatJson::encode( $config ) . " );\n";
 262+
 263+ // FIXME: This loop shades the $name and $module variables from the outer loop. WTF?
262264 foreach ( self::$modules as $name => $module ) {
263265 $loader = $module->getLoaderScript();
264266 if ( $loader !== false ) {
265267 $scripts .= $loader;
266268 } else {
267 - if ( !count( $module->getDependencies() ) && !in_array( $name, $missing ) ) {
 269+ if ( !count( $module->getDependencies() ) && !in_array( $name, $missing ) && !in_array( $name, $modules ) ) {
268270 $registrations[$name] = $name;
269271 } else {
270272 $registrations[$name] = array( $name, $module->getDependencies() );
271273 if ( in_array( $name, $missing ) ) {
272274 $registrations[$name][] = 'missing';
 275+ } else if ( in_array( $name, $modules ) ) {
 276+ $registrations[$name][] = 'ready';
273277 }
274278 }
275279 }
@@ -300,13 +304,14 @@
301305 $styles = Xml::escapeJsString( $styles );
302306 echo "mediaWiki.loader.implement( '{$name}', function() {\n{$scripts}\n}, '{$styles}', {$messages} );\n";
303307 }
304 - if ( $includeScripts ) {
305 - // Register modules without loaders
306 - echo "mediaWiki.loader.register( " . FormatJson::encode( array_values( $registrations ) ) . " );\n";
307 - }
308308 }
309309
310310 // Final processing
 311+ if ( $includeScripts ) {
 312+ // Register modules without loaders
 313+ echo "mediaWiki.loader.register( " . FormatJson::encode( array_values( $registrations ) ) . " );\n";
 314+ }
 315+
311316 if ( $parameters['only'] == 'styles' ) {
312317 header( 'Content-Type: text/css' );
313318 } else {

Status & tagging log