/** @var string Text for error that occurred last */
protected $error;
+ /** @var callable[] */
+ protected $teardownCallbacks = [];
+
/**
* Run the job
* @return bool Success
return $this->hasRootJobParams() && !empty( $this->params['rootJobIsSelf'] );
}
+ /**
+ * @param callable $callback
+ * @since 1.27
+ */
+ protected function addTeardownCallback( $callback ) {
+ $this->teardownCallbacks[] = $callback;
+ }
+
+ /**
+ * Do any final cleanup after run(), deferred updates, and all DB commits happen
+ *
+ * @since 1.27
+ */
+ public function teardown() {
+ foreach ( $this->teardownCallbacks as $callback ) {
+ call_user_func( $callback );
+ }
+ }
+
/**
* Insert a single job into the queue.
* @return bool True on success
DeferredUpdates::doUpdates();
$this->commitMasterChanges( $job );
+ $job->teardown();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;
public function run() {
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = RequestContext::importScopedSession( $this->params['session'] );
+ $this->addTeardownCallback( function () use ( &$scope ) {
+ ScopedCallback::consume( $scope ); // T126450
+ } );
+
$context = RequestContext::getMain();
$user = $context->getUser();
try {
public function run() {
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = RequestContext::importScopedSession( $this->params['session'] );
+ $this->addTeardownCallback( function () use ( &$scope ) {
+ ScopedCallback::consume( $scope ); // T126450
+ } );
+
$context = RequestContext::getMain();
$user = $context->getUser();
try {