From 3c6a5d961657dc4d2501100113071d13ac587c87 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 21 Aug 2005 07:27:29 +0000 Subject: [PATCH] profiling --- includes/Hooks.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index 021d799cf0..60dfc41b30 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -33,18 +33,23 @@ if (defined('MEDIAWIKI')) { function wfRunHooks($event, $args) { global $wgHooks; + $fname = 'wfRunHooks'; + wfProfileIn( $fname ); if (!is_array($wgHooks)) { wfDieDebugBacktrace("Global hooks array is not an array!\n"); + wfProfileOut( $fname ); return false; } if (!array_key_exists($event, $wgHooks)) { + wfProfileOut( $fname ); return true; } if (!is_array($wgHooks[$event])) { wfDieDebugBacktrace("Hooks array for event '$event' is not an array!\n"); + wfProfileOut( $fname ); return false; } @@ -101,25 +106,34 @@ if (defined('MEDIAWIKI')) { $hook_args = $args; } - /* Call the hook. */ + if ( $object ) { + $func = get_class( $object ) . '::' . $method; + } + + /* Call the hook. */ + wfProfileIn( $func ); if ($object) { $retval = call_user_func_array(array($object, $method), $hook_args); } else { $retval = call_user_func_array($func, $hook_args); } + wfProfileOut( $func ); /* String return is an error; false return means stop processing. */ if (is_string($retval)) { global $wgOut; $wgOut->fatalError($retval); + wfProfileOut( $fname ); return false; } else if (!$retval) { + wfProfileOut( $fname ); return false; } } + wfProfileOut( $fname ); return true; } } /* if defined(MEDIAWIKI) */ -- 2.20.1