remove UTF BOM
[mediawiki.git] / maintenance / refreshLinks.inc
blob285aba764a74cbfd25f58aa0a7740a59ec224e33
1 <?php
3 define( "REPORTING_INTERVAL", 50 );
4 define( "PAUSE_INTERVAL", 50 );
6 function refreshLinks( $start ) {
7         global $wgUser, $wgTitle, $wgArticle, $wgEnablePersistentLC, $wgLinkCache, $wgOut;
9         $dbw =& wfGetDB( DB_MASTER );
10         
11         $end = $dbw->selectField( 'cur_id', 'max(cur_id)', false );
13         print("Refreshing link table. Starting from cur_id $start of $end.\n");
15         # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
16         $wgUser->setOption("math", 3);
18         for ($id = $start; $id <= $end; $id++) {
19                 if ( !($id % REPORTING_INTERVAL) ) {
20                         print "$id\n";
21                 }
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                 $wgLinkCache->forUpdate( true );
36                 $wgOut->addWikiText( $text );
38                 if ( $wgEnablePersistentLC ) {
39                         $wgLinkCache->saveToLinkscc( $id, $dbw->strencode( $wgTitle->getPrefixedDBkey() ) );
40                 }
42                 $linksUpdate = new LinksUpdate( $id, $wgTitle->getPrefixedDBkey() );
43                 $linksUpdate->doDumbUpdate();
44                 $linksUpdate->fixBrokenLinks();
45         }