From 5e0ac5814dcc46fe7e4a1d8a8f37da86aa788f90 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 28 Jul 2014 17:53:34 -0700 Subject: [PATCH] Log errors when several callbacks give exceptions in onTransaction* methods Change-Id: I055f46d98c255749dd64b30bfa2db190ddc73d6b --- includes/db/Database.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 86c2616a52..85f042007f 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -3288,7 +3288,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { protected function runOnTransactionIdleCallbacks() { $autoTrx = $this->getFlag( DBO_TRX ); // automatic begin() enabled? - $e = null; // last exception + $e = $ePrior = null; // last exception do { // callbacks may add callbacks :) $callbacks = $this->mTrxIdleCallbacks; $this->mTrxIdleCallbacks = array(); // recursion guard @@ -3299,6 +3299,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { call_user_func( $phpCallback ); $this->setFlag( $autoTrx ? DBO_TRX : 0 ); // restore automatic begin() } catch ( Exception $e ) { + if ( $ePrior ) { + MWExceptionHandler::logException( $ePrior ); + } + $ePrior = $e; } } } while ( count( $this->mTrxIdleCallbacks ) ); @@ -3314,7 +3318,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @since 1.22 */ protected function runOnTransactionPreCommitCallbacks() { - $e = null; // last exception + $e = $ePrior = null; // last exception do { // callbacks may add callbacks :) $callbacks = $this->mTrxPreCommitCallbacks; $this->mTrxPreCommitCallbacks = array(); // recursion guard @@ -3323,6 +3327,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { list( $phpCallback ) = $callback; call_user_func( $phpCallback ); } catch ( Exception $e ) { + if ( $ePrior ) { + MWExceptionHandler::logException( $ePrior ); + } + $ePrior = $e; } } } while ( count( $this->mTrxPreCommitCallbacks ) ); -- 2.20.1