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