From 7f1d4dfb0eaee992ee1009b5e7f03a96335be1d3 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 21 Apr 2015 16:28:49 -0700 Subject: [PATCH] Enable DBO_TRX for runJobs.php, just like HTTP job runner Change-Id: Ic6fa2f9f0d18aeeb15f482e2faab2ebc56650570 --- maintenance/runJobs.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index c8445da72d..3c5d28be9f 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -52,6 +52,8 @@ class RunJobs extends Maintenance { } public function execute() { + global $wgCommandLineMode; + if ( $this->hasOption( 'procs' ) ) { $procs = intval( $this->getOption( 'procs' ) ); if ( $procs < 1 || $procs > 1000 ) { @@ -64,21 +66,29 @@ class RunJobs extends Maintenance { } } - $json = ( $this->getOption( 'result' ) === 'json' ); + $outputJSON = ( $this->getOption( 'result' ) === 'json' ); + + // Enable DBO_TRX for atomicity; JobRunner manages transactions + // and works well in web server mode already (@TODO: this is a hack) + $wgCommandLineMode = false; $runner = new JobRunner( LoggerFactory::getInstance( 'runJobs' ) ); - if ( !$json ) { + if ( !$outputJSON ) { $runner->setDebugHandler( array( $this, 'debugInternal' ) ); } + $response = $runner->run( array( 'type' => $this->getOption( 'type', false ), 'maxJobs' => $this->getOption( 'maxjobs', false ), 'maxTime' => $this->getOption( 'maxtime', false ), 'throttle' => $this->hasOption( 'nothrottle' ) ? false : true, ) ); - if ( $json ) { + + if ( $outputJSON ) { $this->output( FormatJson::encode( $response, true ) ); } + + $wgCommandLineMode = true; } /** -- 2.20.1