From 62a6b90b2acfb248338a37ed15af047c0d424b4d Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 10 Feb 2015 16:39:24 -0800 Subject: [PATCH] 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 --- includes/registration/ExtensionRegistry.php | 3 +++ 1 file changed, 3 insertions(+) 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; -- 2.20.1