X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=maintenance%2FrunJobs.php;h=86cade293dcbfb990d76af7fa0429429911117c1;hb=4b069cd1b88877fbb253af8780e358d96ba2587c;hp=3864e3c607bb5e2f6754038223d58100214bcb06;hpb=755214a5564be292636737186d0140a730377cbd;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/runJobs.php b/maintenance/runJobs.php index 3864e3c607..86cade293d 100644 --- a/maintenance/runJobs.php +++ b/maintenance/runJobs.php @@ -33,7 +33,7 @@ use MediaWiki\Logger\LoggerFactory; class RunJobs extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Run pending jobs"; + $this->addDescription( 'Run pending jobs' ); $this->addOption( 'maxjobs', 'Maximum number of jobs to run', false, true ); $this->addOption( 'maxtime', 'Maximum amount of wall-clock time', false, true ); $this->addOption( 'type', 'Type of job to run', false, true ); @@ -52,9 +52,7 @@ class RunJobs extends Maintenance { } public function execute() { - if ( wfReadOnly() ) { - $this->error( "Unable to run jobs; the wiki is in read-only mode.", 1 ); // die - } + global $wgCommandLineMode; if ( $this->hasOption( 'procs' ) ) { $procs = intval( $this->getOption( 'procs' ) ); @@ -68,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; } /**