Committed a bunch of live hacks from Wikimedia servers
[lhc/web/wiklou.git] / maintenance / runJobs.php
1 <?php
2
3 $optionsWithArgs = array( 'maxjobs' );
4 $wgUseNormalUser = true;
5 require_once( 'commandLine.inc' );
6 require_once( "$IP/includes/JobQueue.php" );
7 require_once( "$IP/includes/FakeTitle.php" );
8
9 if ( isset( $options['maxjobs'] ) ) {
10 $maxJobs = $options['maxjobs'];
11 } else {
12 $maxJobs = 10000;
13 }
14
15 // Trigger errors on inappropriate use of $wgTitle
16 $wgTitle = new FakeTitle;
17
18 $dbw =& wfGetDB( DB_MASTER );
19 $n = 0;
20 while ( $dbw->selectField( 'job', 'count(*)', '', 'runJobs.php' ) ) {
21 while ( false != ($job = Job::pop()) ) {
22 wfWaitForSlaves( 5 );
23 print $job->id . " " . $job->toString() . "\n";
24 if ( !$job->run() ) {
25 print "Error: {$job->error}\n";
26 }
27 if ( $maxJobs && ++$n > $maxJobs ) {
28 break 2;
29 }
30 }
31 }
32 ?>