Adding updater for new pf_memory field
[lhc/web/wiklou.git] / maintenance / runJobs.php
1 <?php
2
3 $optionsWithArgs = array( 'maxjobs', 'type' );
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 = '';
24 if ($type !== false)
25 $conds = "job_cmd = " . $dbw->addQuotes($type);
26
27 while ( $dbw->selectField( 'job', 'count(*)', $conds, 'runJobs.php' ) ) {
28 $offset=0;
29 for (;;) {
30 $job = ($type == false) ?
31 Job::pop($offset)
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