6177de62c0eaa5efde48277c38fcfba012d32972
[lhc/web/wiklou.git] / maintenance / refreshLinks.php
1 <?php
2 define( "REPORTING_INTERVAL", 50 );
3 define( "PAUSE_INTERVAL", 50 );
4
5 include_once( "commandLine.inc" );
6 error_reporting( E_ALL & (~E_NOTICE) );
7
8
9 if ($argv[2]) {
10 $start = (int)$argv[2];
11 } else {
12 $start = 1;
13 }
14
15 $res = wfQuery("SELECT max(cur_id) as m FROM cur", DB_READ);
16 $row = wfFetchObject( $res );
17 $end = $row->m;
18
19 print("Refreshing link table. Starting from cur_id $start of $end.\n");
20
21 # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
22 $wgUser->setOption("math", 3);
23
24 for ($id = $start; $id <= $end; $id++) {
25 if ( !($id % REPORTING_INTERVAL) ) {
26 print "$id\n";
27 }
28
29 if ( !($id % PAUSE_INTERVAL) ) {
30 sleep(1);
31 }
32
33 $wgTitle = Title::newFromID( $id );
34 if ( is_null( $wgTitle ) ) {
35 continue;
36 }
37
38 $wgArticle = new Article( $wgTitle );
39 $text = $wgArticle->getContent( true );
40 $wgLinkCache = new LinkCache;
41 @$wgOut->addWikiText( $text );
42
43 if ( $wgEnablePersistentLC ) {
44 $wgLinkCache->saveToLinkscc( $id, wfStrencode( $wgTitle->getPrefixedDBkey() ) );
45 }
46
47 $linksUpdate = new LinksUpdate( $id, $wgTitle->getPrefixedDBkey() );
48 $linksUpdate->doDumbUpdate();
49 $linksUpdate->fixBrokenLinks();
50 }
51
52 exit();
53
54 ?>