r110254 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110253‎ | r110254 | r110255 >
Date:19:40, 29 January 2012
Author:krinkle
Status:ok (Comments)
Tags:scaptrap 
Comment:
Add support for loading mediawiki.util from the top by default
* Introduces $wgPreloadJavaScriptMwUtil
* Instead of loading mediawiki.util as base module from the bottom, now loading it from queue position "top" if $wgPreloadJavaScriptMwUtil is true. And if false it'll remain in the bottom in practice as implied by other modules loading it as a dependency (i.e. mediawiki.page.ready depends on it)
* Fixes bug 33746
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -321,6 +321,13 @@
322322 * Support for the deprecated hook MagicWordMagicWords was removed.
323323 * The Xml::namespaceSelector method has been deprecated, please use
324324 Html::namespaceSelector instead (note that the parameters have changed also).
 325+* (bug 33746) Preload popular ResourceLoader modules (mediawiki.util) as stop-gap
 326+ for scripts missing dependencies.
 327+ New configuration variable $wgPreloadJavaScriptMwUtil has been introduced for this
 328+ (set to false by default for new installations). Set to true if your wiki has a large
 329+ amount of user/site scripts that are lacking dependency information. In the short to
 330+ medium term these user/site scripts should be fixed by adding the used modules to the
 331+ dependencies in the module registry and/or wrapping them in a callback to mw.loader.using.
325332
326333 == Compatibility ==
327334
Index: trunk/phase3/includes/OutputPage.php
@@ -2439,12 +2439,12 @@
24402440 * Add the default ResourceLoader modules to this object
24412441 */
24422442 private function addDefaultModules() {
2443 - global $wgIncludeLegacyJavaScript, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
 2443+ global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
 2444+ $wgAjaxWatch, $wgEnableMWSuggest;
24442445
24452446 // Add base resources
24462447 $this->addModules( array(
24472448 'mediawiki.user',
2448 - 'mediawiki.util',
24492449 'mediawiki.page.startup',
24502450 'mediawiki.page.ready',
24512451 ) );
@@ -2452,6 +2452,10 @@
24532453 $this->addModules( 'mediawiki.legacy.wikibits' );
24542454 }
24552455
 2456+ if ( $wgPreloadJavaScriptMwUtil ) {
 2457+ $this->addModules( 'mediawiki.util' );
 2458+ }
 2459+
24562460 // Add various resources if required
24572461 if ( $wgUseAjax ) {
24582462 $this->addModules( 'mediawiki.legacy.ajax' );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2605,6 +2605,19 @@
26062606 $wgIncludeLegacyJavaScript = true;
26072607
26082608 /**
 2609+ * Whether to preload the mediawiki.util module as blocking module in the top queue.
 2610+ * Before MediaWiki 1.19, modules used to load slower/less asynchronous which allowed
 2611+ * modules to lack dependencies on 'popular' modules that were likely loaded already.
 2612+ * This setting is to aid scripts during migration by providing mediawiki.util
 2613+ * unconditionally (which was the most commonly missed dependency).
 2614+ * It doesn't cover all missing dependencies obviously but should fix most of them.
 2615+ * This should be removed at some point after site/user scripts have been fixed.
 2616+ * Enable this if your wiki has a large amount of user/site scripts that are lacking
 2617+ * dependencies.
 2618+ */
 2619+$wgPreloadJavaScriptMwUtil = false;
 2620+
 2621+/**
26092622 * Whether or not to assing configuration variables to the global window object.
26102623 * If this is set to false, old code using deprecated variables like:
26112624 * " if ( window.wgRestrictionEdit ) ..."
Index: trunk/phase3/resources/Resources.php
@@ -592,6 +592,7 @@
593593 'jquery.mwExtension',
594594 ),
595595 'messages' => array( 'showtoc', 'hidetoc' ),
 596+ 'position' => 'top', // For $wgPreloadJavaScriptMwUtil
596597 ),
597598
598599 /* MediaWiki Action */

Comments

#Comment by Catrope (talk | contribs)   14:19, 31 January 2012

Tagging scaptrap: requires that $wgPreloadJavaScriptMwUtil be set to true in WMF config.

#Comment by Edokter (talk | contribs)   22:39, 3 February 2012

With bug 33711/r110542 now loading mw.util as a dependency of mw.page.startup in the top load queue, this revision seems deprecated.

#Comment by Krinkle (talk | contribs)   10:41, 4 February 2012

Yeah, that's true. bug 33711/r110542 is not the same problem though (although it does result in the same solution). As a principle I think we should keep this in, so that if either problem is obsolete, we don't accidentally re-introduce a different problem.

#Comment by IAlex (talk | contribs)   14:02, 12 February 2012

Please create a description page on this wiki for the new setting and link to it from Manual:Configuration settings. Thank you.

#Comment by He7d3r (talk | contribs)   16:34, 18 October 2012

Status & tagging log