5 * @subpackage Maintenance
9 define( "REPORTING_INTERVAL", 50 );
10 define( "PAUSE_INTERVAL", 50 );
12 function refreshLinks( $start ) {
13 global $wgUser, $wgTitle, $wgArticle, $wgEnablePersistentLC, $wgLinkCache, $wgOut;
15 $dbw =& wfGetDB( DB_MASTER );
17 $end = $dbw->selectField( 'cur', 'max(cur_id)', false );
19 print("Refreshing link table. Starting from cur_id $start of $end.\n");
21 # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
22 $wgUser->setOption("math", 3);
25 for ($id = $start; $id <= $end; $id++) {
26 if ( !($id % REPORTING_INTERVAL) ) {
30 if ( !($id % PAUSE_INTERVAL) ) {
34 $wgTitle = Title::newFromID( $id );
35 if ( is_null( $wgTitle ) ) {
40 $wgArticle = new Article( $wgTitle );
41 $text = $wgArticle->getContent( true );
42 $wgLinkCache = new LinkCache;
43 $wgLinkCache->forUpdate( true );
45 global $wgLinkHolders;
46 $wgLinkHolders = array(
47 'namespaces' => array(),
55 # Parse the text and replace links with placeholders
56 $wgOut->addWikiText( $text );
58 # Look up the links in the DB and add them to the link cache
59 $wgOut->transformBuffer( RLH_FOR_UPDATE );
62 if ( $wgEnablePersistentLC ) {
63 $wgLinkCache->saveToLinkscc( $id, $dbw->strencode( $wgTitle->getPrefixedDBkey() ) );
66 $linksUpdate = new LinksUpdate( $id, $wgTitle->getPrefixedDBkey() );
67 $linksUpdate->doDumbUpdate();
68 $linksUpdate->fixBrokenLinks();
69 $dbw->query("COMMIT");