From ff5222b3a06079eb1e10e079e86495e86245d616 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Wed, 6 Sep 2017 21:44:49 +0200 Subject: [PATCH] registration: Improve error message for invalid "callback" in extension.json Getting the following error for an invalid callback is not helpful: Warning: Invalid argument: function: class not found in /includes/registration/ExtensionRegistry.php on line 335 Change-Id: I4dfc011cb0a5cd06f1836d73e58f407d468e4546 --- includes/registration/ExtensionRegistry.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index eac04a9b89..bf33c6cfa7 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -332,6 +332,12 @@ class ExtensionRegistry { } foreach ( $info['callbacks'] as $name => $cb ) { + if ( !is_callable( $cb ) ) { + if ( is_array( $cb ) ) { + $cb = '[ ' . implode( ', ', $cb ) . ' ]'; + } + throw new UnexpectedValueException( "callback '$cb' is not callable" ); + } call_user_func( $cb, $info['credits'][$name] ); } } -- 2.20.1