From: Brion Vibber Date: Mon, 11 Jul 2011 21:39:06 +0000 (+0000) Subject: Followup to r91608: reduce impact of bug 29784 (high jsmin+ memory usage during parsi... X-Git-Tag: 1.31.0-rc.0~28924 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=49d3d18033738b00def81e4a633ea6d706453f6e;p=lhc%2Fweb%2Fwiklou.git Followup to r91608: reduce impact of bug 29784 (high jsmin+ memory usage during parsing) by skipping JS validation on modules backed by files. Unless you're developing them, these will usually be stable, and large individual files like the pre-bundled jQuery can hit memory limits much sooner than we like. Validation on JS from wiki pages is still on by default ($wgResourceLoaderValidateJS = true). Validation on static files can be re-enabled by setting $wgResourceLoaderValidateStaticJS = true (defaults false). --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e6b02f860a..b7b50304df 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2520,11 +2520,24 @@ $wgLegacyJavaScriptGlobals = true; $wgResourceLoaderMaxQueryLength = -1; /** - * If set to true, JavaScript will be parsed prior to minification to validate it. - * Parse errors will result in a JS exception being thrown during module load. + * If set to true, JavaScript modules loaded from wiki pages will be parsed prior + * to minification to validate it. + * + * Parse errors will result in a JS exception being thrown during module load, + * which avoids breaking other modules loaded in the same request. */ $wgResourceLoaderValidateJS = true; +/** + * If set to true, statically-sourced (file-backed) JavaScript resources will + * be parsed for validity before being bundled up into ResourceLoader modules. + * + * This can be helpful for development by providing better error messages in + * default (non-debug) mode, but JavaScript parsing is slow and memory hungry + * and may fail on large pre-bundled frameworks. + */ +$wgResourceLoaderValidateStaticJS = false; + /** @} */ # End of resource loader settings } diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 01c9b59543..e1dfc4945c 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -485,6 +485,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @return String: Concatenated and remapped JavaScript data from $scripts */ protected function readScriptFiles( array $scripts ) { + global $wgResourceLoaderValidateStaticJS; if ( empty( $scripts ) ) { return ''; } @@ -495,7 +496,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { if ( $contents === false ) { throw new MWException( __METHOD__.": script file not found: \"$localPath\"" ); } - $contents = $this->validateScriptFile( $fileName, $contents ); + if ( $wgResourceLoaderValidateStaticJS ) { + // Static files don't really need to be checked as often; unlike + // on-wiki module they shouldn't change unexpectedly without + // admin interference. + $contents = $this->validateScriptFile( $fileName, $contents ); + } $js .= $contents . "\n"; } return $js;