r91914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91913‎ | r91914 | r91915 >
Date:21:39, 11 July 2011
Author:brion
Status:ok
Tags:
Comment:
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).
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -485,6 +485,7 @@
486486 * @return String: Concatenated and remapped JavaScript data from $scripts
487487 */
488488 protected function readScriptFiles( array $scripts ) {
 489+ global $wgResourceLoaderValidateStaticJS;
489490 if ( empty( $scripts ) ) {
490491 return '';
491492 }
@@ -495,7 +496,12 @@
496497 if ( $contents === false ) {
497498 throw new MWException( __METHOD__.": script file not found: \"$localPath\"" );
498499 }
499 - $contents = $this->validateScriptFile( $fileName, $contents );
 500+ if ( $wgResourceLoaderValidateStaticJS ) {
 501+ // Static files don't really need to be checked as often; unlike
 502+ // on-wiki module they shouldn't change unexpectedly without
 503+ // admin interference.
 504+ $contents = $this->validateScriptFile( $fileName, $contents );
 505+ }
500506 $js .= $contents . "\n";
501507 }
502508 return $js;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2520,11 +2520,24 @@
25212521 $wgResourceLoaderMaxQueryLength = -1;
25222522
25232523 /**
2524 - * If set to true, JavaScript will be parsed prior to minification to validate it.
2525 - * Parse errors will result in a JS exception being thrown during module load.
 2524+ * If set to true, JavaScript modules loaded from wiki pages will be parsed prior
 2525+ * to minification to validate it.
 2526+ *
 2527+ * Parse errors will result in a JS exception being thrown during module load,
 2528+ * which avoids breaking other modules loaded in the same request.
25262529 */
25272530 $wgResourceLoaderValidateJS = true;
25282531
 2532+/**
 2533+ * If set to true, statically-sourced (file-backed) JavaScript resources will
 2534+ * be parsed for validity before being bundled up into ResourceLoader modules.
 2535+ *
 2536+ * This can be helpful for development by providing better error messages in
 2537+ * default (non-debug) mode, but JavaScript parsing is slow and memory hungry
 2538+ * and may fail on large pre-bundled frameworks.
 2539+ */
 2540+$wgResourceLoaderValidateStaticJS = false;
 2541+
25292542 /** @} */ # End of resource loader settings }
25302543
25312544

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91608* (bug 28626) Validate JavaScript files and pages loaded via ResourceLoader b...brion21:48, 6 July 2011

Status & tagging log