X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHooks.php;h=89457e84362cb2269ad25a8956aa486dc2f42d86;hb=a5d145ae3ccb14f0f5e99a769eadfeb70755a972;hp=db47d3194eaf6fdc948496956613715290c62350;hpb=30cca9fe5c37903ee342851afec811a4fe54e933;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Hooks.php b/includes/Hooks.php index db47d3194e..89457e8436 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -27,7 +27,8 @@ /** * @since 1.18 */ -class MWHookException extends MWException {} +class MWHookException extends MWException { +} /** * Hooks class. @@ -37,7 +38,6 @@ class MWHookException extends MWException {} * @since 1.18 */ class Hooks { - /** * Array of events mapped to an array of callbacks to be run * when that event is triggered. @@ -124,6 +124,7 @@ class Hooks { * * @param string $event Event name * @param array $args Array of parameters passed to hook functions + * @param string|null $deprecatedVersion Optionally, mark hook as deprecated with version number * @return bool True if no handler aborted the hook * * @since 1.22 A hook function is not required to return a value for @@ -132,7 +133,7 @@ class Hooks { * @throws MWException * @throws FatalError */ - public static function run( $event, array $args = array() ) { + public static function run( $event, array $args = array(), $deprecatedVersion = null ) { wfProfileIn( 'hook: ' . $event ); foreach ( self::getHandlers( $event ) as $hook ) { // Turn non-array values into an array. (Can't use casting because of objects.) @@ -195,6 +196,12 @@ class Hooks { // Profile first in case the Profiler causes errors. wfProfileIn( $func ); set_error_handler( 'Hooks::hookErrorHandler' ); + + // mark hook as deprecated, if deprecation version is specified + if ( $deprecatedVersion !== null ) { + wfDeprecated( "$event hook (used in $func)", $deprecatedVersion ); + } + try { $retval = call_user_func_array( $callback, $hook_args ); } catch ( MWHookException $e ) {