Localisation updates for core and extension messages from translatewiki.net (2010...
[lhc/web/wiklou.git] / includes / Hooks.php
index 01810b2..168f4bd 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
- * Hooks.php -- a tool for running hook functions
+ * A tool for running hook functions.
+ *
  * Copyright 2004, 2005 Evan Prodromou <evan@wikitravel.org>.
  *
  *  This program is free software; you can redistribute it and/or modify
 
 
 /**
+ * Call hook functions defined in $wgHooks
+ *
  * Because programmers assign to $wgHooks, we need to be very
  * careful about its contents. So, there's a lot more error-checking
  * in here than would normally be necessary.
+ *
+ * @param $event String: event name
+ * @param $args Array: parameters passed to hook functions
+ * @return Boolean
  */
 function wfRunHooks($event, $args = array()) {
 
@@ -39,12 +46,10 @@ function wfRunHooks($event, $args = array()) {
 
        if (!is_array($wgHooks)) {
                throw new MWException("Global hooks array is not an array!\n");
-               return false;
        }
 
        if (!is_array($wgHooks[$event])) {
                throw new MWException("Hooks array for event '$event' is not an array!\n");
-               return false;
        }
 
        foreach ($wgHooks[$event] as $index => $hook) {
@@ -147,7 +152,7 @@ function wfRunHooks($event, $args = array()) {
                 * problem here.
                 */
                $retval = null;
-               $handler = set_error_handler( 'hookErrorHandler' );
+               set_error_handler( 'hookErrorHandler' );
                wfProfileIn( $func );
                try {
                        $retval = call_user_func_array( $callback, $hook_args );
@@ -155,11 +160,9 @@ function wfRunHooks($event, $args = array()) {
                        $badhookmsg = $e->getMessage();
                }
                wfProfileOut( $func );
-               // Need to check for null, because set_error_handler borks on it... sigh
-               if ( $handler !== null ) set_error_handler( $handler );
+               restore_error_handler();
 
                /* String return is an error; false return means stop processing. */
-
                if ( is_string( $retval ) ) {
                        global $wgOut;
                        $wgOut->showFatalError( $retval );