und -> and ;)
[mediawiki.git] / maintenance / runJobs.php
blobcee9cb1e02e81a9ced368f7ad8163348d55b1dcc
1 <?php
2 /**
3 * This script starts pending jobs.
5 * Usage:
6 * --maxjobs <num> (default 10000)
7 * --type <job_cmd>
9 * @file
10 * @ingroup Maintenance
13 $optionsWithArgs = array( 'maxjobs', 'type' );
14 $wgUseNormalUser = true;
15 require_once( 'commandLine.inc' );
16 require_once( "$IP/includes/JobQueue.php" );
17 require_once( "$IP/includes/FakeTitle.php" );
19 if ( isset( $options['maxjobs'] ) ) {
20 $maxJobs = $options['maxjobs'];
21 } else {
22 $maxJobs = 10000;
25 $type = false;
26 if ( isset( $options['type'] ) )
27 $type = $options['type'];
29 $wgTitle = Title::newFromText( 'RunJobs.php' );
31 $dbw = wfGetDB( DB_MASTER );
32 $n = 0;
33 $conds = '';
34 if ($type !== false)
35 $conds = "job_cmd = " . $dbw->addQuotes($type);
37 while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
38 $offset=0;
39 for (;;) {
40 $job = ($type == false) ?
41 Job::pop($offset)
42 : Job::pop_type($type);
44 if ($job == false)
45 break;
47 wfWaitForSlaves( 5 );
48 print wfTimestamp( TS_DB ) . " " . $job->id . " " . $job->toString() . "\n";
49 $offset=$job->id;
50 if ( !$job->run() ) {
51 print wfTimestamp( TS_DB ) . " Error: {$job->error}\n";
53 if ( $maxJobs && ++$n > $maxJobs ) {
54 break 2;