From: Alexandre Emsenhuber Date: Thu, 12 Jul 2012 21:07:56 +0000 (+0200) Subject: Catch exceptions thrown while running deferred updates. X-Git-Tag: 1.31.0-rc.0~23061 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=e1bc8fd885e1f06603dcd024bea29236863f1480;p=lhc%2Fweb%2Fwiklou.git Catch exceptions thrown while running deferred updates. Such exceptions should not reported to the user because the main output is already sent. Otherwise the user will recive a double reponse with is just horribly looking. Instead just log these exceptions to keep a trace of them. This also adds an higher isolation level for these updates and the post-response cleanup. Change-Id: I60c2c5ba8ab2ec2d835d8d3042584e98a62809be --- diff --git a/includes/DeferredUpdates.php b/includes/DeferredUpdates.php index 00af974143..b4989a6997 100644 --- a/includes/DeferredUpdates.php +++ b/includes/DeferredUpdates.php @@ -88,10 +88,19 @@ class DeferredUpdates { } foreach ( $updates as $update ) { - $update->doUpdate(); + try { + $update->doUpdate(); - if ( $doCommit && $dbw->trxLevel() ) { - $dbw->commit( __METHOD__ ); + if ( $doCommit && $dbw->trxLevel() ) { + $dbw->commit( __METHOD__ ); + } + } catch ( MWException $e ) { + // We don't want exceptions thrown during deferred updates to + // be reported to the user since the output is already sent. + // Instead we just log them. + if ( !$e instanceof ErrorPageError ) { + wfDebugLog( 'exception', $e->getLogMessage() ); + } } }