From: Gergő Tisza Date: Wed, 5 Oct 2016 01:16:56 +0000 (+0000) Subject: Pass Job success status to teardown callbacks X-Git-Tag: 1.31.0-rc.0~5208^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/%7B%7B%20url_for%28%27vote%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=d304f5e3947b969a7dce87cd5336e61d9b683206;p=lhc%2Fweb%2Fwiklou.git Pass Job success status to teardown callbacks Change-Id: Icf2e03efcfd9232fe4ead776096b61cef1c06141 --- diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php index bbd0ddb5f8..f814ceeb1b 100644 --- a/includes/jobqueue/Job.php +++ b/includes/jobqueue/Job.php @@ -301,7 +301,9 @@ abstract class Job implements IJobSpecification { } /** - * @param callable $callback + * @param callable $callback A function with one parameter, the success status, which will be + * false if the job failed or it succeeded but the DB changes could not be committed or + * any deferred updates threw an exception. (This parameter was added in 1.28.) * @since 1.27 */ protected function addTeardownCallback( $callback ) { @@ -310,12 +312,12 @@ abstract class Job implements IJobSpecification { /** * Do any final cleanup after run(), deferred updates, and all DB commits happen - * + * @param bool $status Whether the job, its deferred updates, and DB commit all succeeded * @since 1.27 */ - public function teardown() { + public function teardown( $status ) { foreach ( $this->teardownCallbacks as $callback ) { - call_user_func( $callback ); + call_user_func( $callback, $status ); } } diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index ed3aa9af69..84ded8d94e 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -283,7 +283,7 @@ class JobRunner implements LoggerAwareInterface { } // Always attempt to call teardown() even if Job throws exception. try { - $job->teardown(); + $job->teardown( $status ); } catch ( Exception $e ) { MWExceptionHandler::logException( $e ); }