- wfProfileOut( $func );
- restore_error_handler();
-
- /* String return is an error; false return means stop processing. */
- if ( is_string( $retval ) ) {
- global $wgOut;
- $wgOut->showFatalError( $retval );
- return false;
- } elseif( $retval === null ) {
- if ( $closure ) {
- $prettyFunc = "$event closure";
- } elseif( is_array( $callback ) ) {
- if( is_object( $callback[0] ) ) {
- $prettyClass = get_class( $callback[0] );
- } else {
- $prettyClass = strval( $callback[0] );
- }
- $prettyFunc = $prettyClass . '::' . strval( $callback[1] );
- } else {
- $prettyFunc = strval( $callback );
+
+ // Call the hook.
+ $hook_args = array_merge( $hook, $args );
+ return call_user_func_array( $callback, $hook_args );
+ }
+
+ /**
+ * Call hook functions defined in Hooks::register and $wgHooks.
+ *
+ * For the given hook event, fetch the array of hook events and
+ * process them. Determine the proper callback for each hook and
+ * then call the actual hook using the appropriate arguments.
+ * Finally, process the return value and return/throw accordingly.
+ *
+ * For hook event that are not abortable through a handler's return value,
+ * use runWithoutAbort() instead.
+ *
+ * @param string $event Event name
+ * @param array $args Array of parameters passed to hook functions
+ * @param string|null $deprecatedVersion [optional] Mark hook as deprecated with version number
+ * @return bool True if no handler aborted the hook
+ *
+ * @throws Exception
+ * @throws FatalError
+ * @throws MWException
+ * @since 1.22 A hook function is not required to return a value for
+ * processing to continue. Not returning a value (or explicitly
+ * returning null) is equivalent to returning true.
+ */
+ public static function run( $event, array $args = [], $deprecatedVersion = null ) {
+ foreach ( self::getHandlers( $event ) as $hook ) {
+ $retval = self::callHook( $event, $hook, $args, $deprecatedVersion );
+ if ( $retval === null ) {
+ continue;