Catch exceptions thrown while running deferred updates.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 12 Jul 2012 21:07:56 +0000 (23:07 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 12 Jul 2012 21:14:40 +0000 (23:14 +0200)
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

includes/DeferredUpdates.php

index 00af974..b4989a6 100644 (file)
@@ -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() );
+                               }
                        }
                }