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).
This commit is contained in:
Brion Vibber 2011-07-11 21:39:06 +00:00
parent 06217b2f2f
commit 49d3d18033
2 changed files with 22 additions and 3 deletions

View file

@ -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 }

View file

@ -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;