From: Kunal Mehta Date: Wed, 11 Feb 2015 00:39:24 +0000 (-0800) Subject: registration: Throw an Exception if a JSON file is invalid X-Git-Tag: 1.31.0-rc.0~12456^2 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=62a6b90b2acfb248338a37ed15af047c0d424b4d;p=lhc%2Fweb%2Fwiklou.git registration: Throw an Exception if a JSON file is invalid Currently you get confusing fatals like: Argument 2 passed to ExtensionRegistry::processAutoLoader() must be an array, null given Change-Id: Icc7198db152e071c5a42e06547268fbaee916107 --- diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 4605ca52a5..8541e319ef 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -96,6 +96,9 @@ class ExtensionRegistry { foreach ( $this->queued as $path => $mtime ) { $json = file_get_contents( $path ); $info = json_decode( $json, /* $assoc = */ true ); + if ( !is_array( $info ) ) { + throw new Exception( "$path is not a valid JSON file." ); + } $autoload = $this->processAutoLoader( dirname( $path ), $info ); // Set up the autoloader now so custom processors will work $GLOBALS['wgAutoloadClasses'] += $autoload;