From: Krinkle Date: Sun, 29 Jan 2012 19:40:11 +0000 (+0000) Subject: Add support for loading mediawiki.util from the top by default X-Git-Tag: 1.31.0-rc.0~25026 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22brouteur%22%2C%28%24id_rubrique%20?a=commitdiff_plain;h=3c72b527edd7ad85b7c3d690f239cdc20770cd1e;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 92ff7df817..80ca445ab8 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -321,6 +321,13 @@ changes to languages because of Bugzilla reports. * Support for the deprecated hook MagicWordMagicWords was removed. * The Xml::namespaceSelector method has been deprecated, please use Html::namespaceSelector instead (note that the parameters have changed also). +* (bug 33746) Preload popular ResourceLoader modules (mediawiki.util) as stop-gap + for scripts missing dependencies. + New configuration variable $wgPreloadJavaScriptMwUtil has been introduced for this + (set to false by default for new installations). Set to true if your wiki has a large + amount of user/site scripts that are lacking dependency information. In the short to + medium term these user/site scripts should be fixed by adding the used modules to the + dependencies in the module registry and/or wrapping them in a callback to mw.loader.using. == Compatibility == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6d588f7df3..20e43ab73b 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2604,6 +2604,19 @@ $wgResourceLoaderMinifierMaxLineLength = 1000; */ $wgIncludeLegacyJavaScript = true; +/** + * Whether to preload the mediawiki.util module as blocking module in the top queue. + * Before MediaWiki 1.19, modules used to load slower/less asynchronous which allowed + * modules to lack dependencies on 'popular' modules that were likely loaded already. + * This setting is to aid scripts during migration by providing mediawiki.util + * unconditionally (which was the most commonly missed dependency). + * It doesn't cover all missing dependencies obviously but should fix most of them. + * This should be removed at some point after site/user scripts have been fixed. + * Enable this if your wiki has a large amount of user/site scripts that are lacking + * dependencies. + */ +$wgPreloadJavaScriptMwUtil = false; + /** * Whether or not to assing configuration variables to the global window object. * If this is set to false, old code using deprecated variables like: diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 70a8c53d22..16e158de93 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2439,12 +2439,12 @@ $templates * Add the default ResourceLoader modules to this object */ private function addDefaultModules() { - global $wgIncludeLegacyJavaScript, $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest; + global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax, + $wgAjaxWatch, $wgEnableMWSuggest; // Add base resources $this->addModules( array( 'mediawiki.user', - 'mediawiki.util', 'mediawiki.page.startup', 'mediawiki.page.ready', ) ); @@ -2452,6 +2452,10 @@ $templates $this->addModules( 'mediawiki.legacy.wikibits' ); } + if ( $wgPreloadJavaScriptMwUtil ) { + $this->addModules( 'mediawiki.util' ); + } + // Add various resources if required if ( $wgUseAjax ) { $this->addModules( 'mediawiki.legacy.ajax' ); diff --git a/resources/Resources.php b/resources/Resources.php index 1830ba9fa3..42dfb41c1b 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -592,6 +592,7 @@ return array( 'jquery.mwExtension', ), 'messages' => array( 'showtoc', 'hidetoc' ), + 'position' => 'top', // For $wgPreloadJavaScriptMwUtil ), /* MediaWiki Action */