5 * @subpackage Maintenance
10 define( "REPORTING_INTERVAL", 50 );
11 define( "PAUSE_INTERVAL", 50 );
13 function refreshLinks( $start ) {
14 global $wgUser, $wgTitle, $wgArticle, $wgEnablePersistentLC, $wgLinkCache, $wgOut;
16 $dbw =& wfGetDB( DB_MASTER );
18 $end = $dbw->selectField( 'cur', 'max(cur_id)', false );
20 print("Refreshing link table. Starting from cur_id $start of $end.\n");
22 # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
23 $wgUser->setOption("math", 3);
26 for ($id = $start; $id <= $end; $id++) {
27 if ( !($id % REPORTING_INTERVAL) ) {
31 if ( !($id % PAUSE_INTERVAL) ) {
35 $wgTitle = Title::newFromID( $id );
36 if ( is_null( $wgTitle ) ) {
41 $wgArticle = new Article( $wgTitle );
42 $text = $wgArticle->getContent( true );
43 $wgLinkCache = new LinkCache;
44 $wgLinkCache->forUpdate( true );
46 # Parse the text and replace links with placeholders
47 $wgOut->addWikiText( $text );
49 # Look up the links in the DB and add them to the link cache
50 $wgOut->transformBuffer( RLH_FOR_UPDATE );
53 if ( $wgEnablePersistentLC ) {
54 $wgLinkCache->saveToLinkscc( $id, $dbw->strencode( $wgTitle->getPrefixedDBkey() ) );
57 $linksUpdate = new LinksUpdate( $id, $wgTitle->getPrefixedDBkey() );
59 * In ./includes/LinksUpdate.php doDumbUpdate is commented with:
60 * "Old inefficient update function"
61 * Probably need to call doUpdate instead.
63 $linksUpdate->doDumbUpdate();
64 $linksUpdate->fixBrokenLinks();
65 $dbw->query("COMMIT");