From: Brian Wolff Date: Mon, 16 May 2016 05:26:55 +0000 (-0400) Subject: Call $job->teardown() even if Job throws an exception. X-Git-Tag: 1.31.0-rc.0~6969^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=fb7b637660638ad3329bc8a417ba12df632ff1f0;p=lhc%2Fweb%2Fwiklou.git Call $job->teardown() even if Job throws an exception. teardown() callbacks are primarily used to reset session after job is done. It seems important to do this, even if exception is thrown by job. Change-Id: I0bd449414527321b0ed9063cea268dea5b0766c4 --- diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index a2f55b9e04..1350958b78 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -268,13 +268,19 @@ class JobRunner implements LoggerAwareInterface { DeferredUpdates::doUpdates(); $this->commitMasterChanges( $job ); - $job->teardown(); } catch ( Exception $e ) { MWExceptionHandler::rollbackMasterChangesAndLog( $e ); $status = false; $error = get_class( $e ) . ': ' . $e->getMessage(); MWExceptionHandler::logException( $e ); } + // Always attempt to call teardown() even if Job throws exception. + try { + $job->teardown(); + } catch ( Exception $e ) { + MWExceptionHandler::logException( $e ); + } + // Commit all outstanding connections that are in a transaction // to get a fresh repeatable read snapshot on every connection. // Note that jobs are still responsible for handling slave lag.