From: Timo Tijhof Date: Wed, 13 Feb 2019 01:45:56 +0000 (+0000) Subject: resourceloader: Ignore warnings in JSMinPlus parser X-Git-Tag: 1.34.0-rc.0~2833^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=7a72b16e0f4c3ef1f0befc330458e8eadd5f32b9;p=lhc%2Fweb%2Fwiklou.git resourceloader: Ignore warnings in JSMinPlus parser It's old and unmaintained. The only thing we care about is if it was able to parse the script and if not, what its error is. Its return value or broken inner workings are insignificant at this point and only cause noise. Bug: T77169 Change-Id: Ie357ccfcc6141f894b452eb3996e168c1526990f --- diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index ae79dda520..b39262527c 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -956,16 +956,25 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { $cache::TTL_WEEK, function () use ( $contents, $fileName ) { $parser = self::javaScriptParser(); + $err = null; try { + Wikimedia\suppressWarnings(); $parser->parse( $contents, $fileName, 1 ); - $result = $contents; } catch ( Exception $e ) { - // We'll save this to cache to avoid having to re-validate broken JS - $err = $e->getMessage(); - $result = "mw.log.error(" . - Xml::encodeJsVar( "JavaScript parse error: $err" ) . ");"; + $err = $e; + } finally { + Wikimedia\restoreWarnings(); } - return $result; + if ( $err ) { + // Send the error to the browser console client-side. + // By returning this as replacement for the actual script, + // we ensure modules are safe to load in a batch request, + // without causing other unrelated modules to break. + return 'mw.log.error(' . + Xml::encodeJsVar( 'JavaScript parse error: ' . $err->getMessage() ) . + ');'; + } + return $contents; } ); }