From: Brian Wolff Date: Sun, 6 Apr 2014 02:02:02 +0000 (-0300) Subject: Rollback transaction in case of uncaught exceptions during job X-Git-Tag: 1.31.0-rc.0~16361^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=2ab242ae0fb4d34c1eeca16c9602b8af821dd787;p=lhc%2Fweb%2Fwiklou.git Rollback transaction in case of uncaught exceptions during job If there is an unhandled exception during a job, rollback the transaction to be safe. Otherwise its likely that the transaction will be commited when next job is run, as $dbw->begin() implicitly commits any open pending transactions. This can result in database referential integrity issues. Change-Id: I5807e64440ff6c6651fbbb4924645d05d843b98e --- diff --git a/includes/specials/SpecialRunJobs.php b/includes/specials/SpecialRunJobs.php index 0c4528182e..104cd54db0 100644 --- a/includes/specials/SpecialRunJobs.php +++ b/includes/specials/SpecialRunJobs.php @@ -152,6 +152,7 @@ class SpecialRunJobs extends UnlistedSpecialPage { } } while ( --$n && $job ); } catch ( MWException $e ) { + MWExceptionHandler::rollbackMasterChangesAndLog( $e ); // We don't want exceptions thrown during job execution to // be reported to the user since the output is already sent. // Instead we just log them. diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index f7d5fc07e7..cd657ac2c1 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -103,6 +103,7 @@ class RunJobs extends Maintenance { $status = $job->run(); $error = $job->getLastError(); } catch ( MWException $e ) { + MWExceptionHandler::rollbackMasterChangesAndLog( $e ); $status = false; $error = get_class( $e ) . ': ' . $e->getMessage(); $e->report(); // write error to STDERR and the log