summaryrefslogtreecommitdiff
path: root/maintenance/runJobs.php
blob: 343cda8a3a0c5f3cad57dc6ea4cdeb6d0e157ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

$optionsWithArgs = array( 'maxjobs' );
$wgUseNormalUser = true;
require_once( 'commandLine.inc' );
require_once( "$IP/includes/JobQueue.php" );
require_once( "$IP/includes/FakeTitle.php" );

if ( isset( $options['maxjobs'] ) ) {
	$maxJobs = $options['maxjobs'];
} else {
	$maxJobs = 10000;
}

// Trigger errors on inappropriate use of $wgTitle
$wgTitle = new FakeTitle;

$dbw =& wfGetDB( DB_MASTER );
$n = 0;
while ( $dbw->selectField( 'job', 'count(*)', '', 'runJobs.php' ) ) {
	while ( false != ($job = Job::pop()) ) {
		wfWaitForSlaves( 5 );
		print $job->id . "  " . $job->toString() . "\n";
		if ( !$job->run() ) {
			print "Error: {$job->error}\n";
		}
		if ( $maxJobs && ++$n > $maxJobs ) {
			break 2;
		}
	}
}
?>