new link rebuilder, capable of operating in the background
[lhc/web/wiklou.git] / maintenance / refreshLinks.php
1 <?php
2 define( "REPORTING_INTERVAL", 500 );
3
4 include_once( "commandLine.inc" );
5
6 if ($argv[2]) {
7 $start = (int)$argv[2];
8 } else {
9 $start = 1;
10 }
11
12 $res = wfQuery("SELECT max(cur_id) as m FROM cur", DB_READ);
13 $row = wfFetchObject( $res );
14 $end = $row->m;
15
16 print("Refreshing link table. Starting from cur_id $start of $end.\n");
17
18 for ($id = start; $id <= $end; $id++) {
19 if ( !($id % REPORTING_INTERVAL) ) {
20 print $id;
21 }
22
23 $wgTitle = Title::newFromID( $id );
24 if ( $wgTitle == NULL ) {
25 continue;
26 }
27
28 $wgLinkCache = new LinkCache;
29 $wgArticle = new Article( $wgTitle );
30 $text = $wgArticle->getContent( true );
31 $wgOut->addWikiText( $text );
32
33 $linksUpdate = new LinksUpdate( $id, $wgTitle );
34 $linksUpdate->doDumbUpdate();
35 }
36
37
38 exit();
39
40 ?>