Add tests for parser tag hooks.
[lhc/web/wiklou.git] / maintenance / gearman / gearmanRefreshLinks.php
1 <?php
2
3 $optionsWithArgs = array( 'fake-job' );
4
5 require( dirname( __FILE__ ) . '/../commandLine.inc' );
6 require( dirname( __FILE__ ) . '/gearman.inc' );
7
8 if ( !$args ) {
9 $args = array( 'localhost' );
10 }
11 $client = new Net_Gearman_Client( $args );
12 $batchSize = 1000;
13
14 $dbr = wfGetDB( DB_SLAVE );
15 $startId = 0;
16 $endId = $dbr->selectField( 'page', 'MAX(page_id)', false, __METHOD__ );
17 while ( true ) {
18 $res = $dbr->select(
19 'page',
20 array( 'page_namespace', 'page_title', 'page_id' ),
21 array( 'page_id > ' . intval( $startId ) ),
22 __METHOD__,
23 array( 'LIMIT' => $batchSize )
24 );
25
26 if ( $res->numRows() == 0 ) {
27 break;
28 }
29 $set = new Net_Gearman_Set;
30 foreach ( $res as $row ) {
31 $startId = $row->page_id;
32 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
33 $params = array(
34 'wiki' => wfWikiID(),
35 'title' => $title->getPrefixedDBkey(),
36 'command' => 'refreshLinks',
37 'params' => false,
38 );
39 $task = new Net_Gearman_Task( 'mw_job', $params );
40 $set->addTask( $task );
41 }
42 $client->runSet( $set );
43 print "$startId / $endId\n";
44 }
45