]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/runJobs.php
MediaWiki 1.11.0
[autoinstallsdev/mediawiki.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 $type = false;
16 if ( isset( $options['type'] ) )
17         $type = $options['type'];
18
19 $wgTitle = Title::newFromText( 'RunJobs.php' );
20
21 $dbw = wfGetDB( DB_MASTER );
22 $n = 0;
23 $conds = array();
24 if ($type !== false)
25         $conds = array('job_cmd' => $type);
26
27 while ( $dbw->selectField( 'job', 'count(*)', $conds, 'runJobs.php' ) ) {
28         $offset=0;
29         for (;;) {
30                 $job = ($type == false) ?
31                                 Job::pop($offset, $type)
32                                 : Job::pop_type($type);
33
34                 if ($job == false)
35                         break;
36
37                 wfWaitForSlaves( 5 );
38                 print $job->id . "  " . $job->toString() . "\n";
39                 $offset=$job->id;
40                 if ( !$job->run() ) {
41                         print "Error: {$job->error}\n";
42                 }
43                 if ( $maxJobs && ++$n > $maxJobs ) {
44                         break 2;
45                 }
46         }
47 }
48