Make sure we always restore the error handler.
authordaniel <daniel.kinzler@wikimedia.de>
Fri, 15 Nov 2013 15:13:19 +0000 (16:13 +0100)
committerAude <aude.wiki@gmail.com>
Fri, 15 Nov 2013 16:57:34 +0000 (16:57 +0000)
Change-Id: I27f5d11ea27f783eda71c2bfdba7e70695f5d53c

includes/Hooks.php
includes/UserMailer.php
includes/db/DatabaseMysqlBase.php
includes/db/DatabasePostgres.php
includes/installer/WebInstaller.php

index 396e360..db47d31 100644 (file)
@@ -199,6 +199,9 @@ class Hooks {
                                $retval = call_user_func_array( $callback, $hook_args );
                        } catch ( MWHookException $e ) {
                                $badhookmsg = $e->getMessage();
+                       } catch ( Exception $e ) {
+                               restore_error_handler();
+                               throw $e;
                        }
                        restore_error_handler();
                        wfProfileOut( $func );
index 8ab10b2..6157f78 100644 (file)
@@ -352,14 +352,19 @@ class UserMailer {
                        ini_set( 'html_errors', '0' );
                        set_error_handler( 'UserMailer::errorHandler' );
 
-                       $safeMode = wfIniGetBool( 'safe_mode' );
-
-                       foreach ( $to as $recip ) {
-                               if ( $safeMode ) {
-                                       $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers );
-                               } else {
-                                       $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
+                       try {
+                               $safeMode = wfIniGetBool( 'safe_mode' );
+
+                               foreach ( $to as $recip ) {
+                                       if ( $safeMode ) {
+                                               $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers );
+                                       } else {
+                                               $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
+                                       }
                                }
+                       } catch ( Exception $e ) {
+                               restore_error_handler();
+                               throw $e;
                        }
 
                        restore_error_handler();
index 26c9d24..cdfa769 100644 (file)
@@ -76,6 +76,7 @@ abstract class DatabaseMysqlBase extends DatabaseBase {
                } catch ( Exception $ex ) {
                        wfProfileOut( "dbconnect-$server" );
                        wfProfileOut( __METHOD__ );
+                       $this->restoreErrorHandler();
                        throw $ex;
                }
                $error = $this->restoreErrorHandler();
index e564a16..72371a2 100644 (file)
@@ -370,7 +370,14 @@ class DatabasePostgres extends DatabaseBase {
                $this->connectString = $this->makeConnectionString( $connectVars, PGSQL_CONNECT_FORCE_NEW );
                $this->close();
                $this->installErrorHandler();
-               $this->mConn = pg_connect( $this->connectString );
+
+               try {
+                       $this->mConn = pg_connect( $this->connectString );
+               } catch ( Exception $ex ) {
+                       $this->restoreErrorHandler();
+                       throw $ex;
+               }
+
                $phpError = $this->restoreErrorHandler();
 
                if ( !$this->mConn ) {
index 53cb7dc..b37e6b3 100644 (file)
@@ -336,7 +336,12 @@ class WebInstaller extends Installer {
 
                $this->phpErrors = array();
                set_error_handler( array( $this, 'errorHandler' ) );
-               session_start();
+               try {
+                       session_start();
+               } catch ( Exception $e ) {
+                       restore_error_handler();
+                       throw $e;
+               }
                restore_error_handler();
 
                if ( $this->phpErrors ) {