3 # Remove spurious brokenlinks
4 require_once( "commandLine.inc" );
5 require_once( "./rebuildrecentchanges.inc" );
6 $wgTitle = Title
::newFromText( "Rebuild brokenlinks script" );
10 echo "Checking for broken brokenlinks...\n";
12 $dbw =& wfGetDB( DB_MASTER
);
13 extract( $dbw->tableNames( 'brokenlinks', 'cur', 'linkscc' );
15 $res = $dbw->select( 'cur', array( 'cur_namespace', 'cur_title', 'cur_id' ), false );
17 while( $s = $dbw->fetchObject( $res ) ) {
22 $title = Title
::makeTitle( $s->cur_namespace
, $s->cur_title
);
24 $t = $title->getPrefixedDBKey();
25 $tt = $dbw->strencode( $t );
27 $sql2 = "SELECT bl_from,cur_id,cur_namespace,cur_title FROM $brokenlinks,$cur " .
28 "WHERE bl_to='$tt' AND cur_id=bl_from";
29 $res2 = $dbw->query( $sql2 );
30 while( $s = $dbw->fetchObject( $res2 ) ) {
31 $from = Title
::makeTitle( $s->cur_namespace
, $s->cur_title
);
32 $xt = $from->getPrefixedText();
33 echo "Found bad brokenlink to [[$t]] from page #$s->cur_id [[$xt]]!\n";
36 $dbw->freeResult( $res2 );
38 echo "Removing brokenlinks to [[$t]]...\n";
39 $sql3 = "DELETE FROM $brokenlinks WHERE bl_to='$tt'";
40 $res3 = $dbw->query( $sql3 );
44 echo "Illegal title?! Namespace $s->cur_namespace, title '$s->cur_title'\n";
47 echo "Done at $n.\n\n";
49 echo "Clearing linkscc table...\n";
50 $sql4 = "DELETE FROM $linkscc";
51 wfQuery( $sql4, DB_MASTER
);