From: Umherirrender Date: Wed, 6 Sep 2017 19:44:49 +0000 (+0200) Subject: registration: Improve error message for invalid "callback" in extension.json X-Git-Tag: 1.31.0-rc.0~2172^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=ff5222b3a06079eb1e10e079e86495e86245d616;p=lhc%2Fweb%2Fwiklou.git 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 --- 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] ); } }