selectField( 'cur', 'max(cur_id)', false ); print("Refreshing link table. Starting from cur_id $start of $end.\n"); # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway) $wgUser->setOption("math", 3); for ($id = $start; $id <= $end; $id++) { if ( !($id % REPORTING_INTERVAL) ) { print "$id\n"; } if ( !($id % PAUSE_INTERVAL) ) { sleep(1); } $wgTitle = Title::newFromID( $id ); if ( is_null( $wgTitle ) ) { continue; } $dbw->query("BEGIN"); $wgArticle = new Article( $wgTitle ); $text = $wgArticle->getContent( true ); $wgLinkCache = new LinkCache; $wgLinkCache->forUpdate( true ); global $wgLinkHolders; $wgLinkHolders = array( 'namespaces' => array(), 'dbkeys' => array(), 'queries' => array(), 'texts' => array(), 'titles' => array() ); # Parse the text and replace links with placeholders $wgOut->addWikiText( $text ); # Look up the links in the DB and add them to the link cache $wgOut->transformBuffer( RLH_FOR_UPDATE ); $wgOut->clearHTML(); if ( $wgEnablePersistentLC ) { $wgLinkCache->saveToLinkscc( $id, $dbw->strencode( $wgTitle->getPrefixedDBkey() ) ); } $linksUpdate = new LinksUpdate( $id, $wgTitle->getPrefixedDBkey() ); $linksUpdate->doDumbUpdate(); $linksUpdate->fixBrokenLinks(); $dbw->query("COMMIT"); } } ?>