Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

remove-brokenlinks.php

Go to the documentation of this file.
00001 <?php 00002 00003 # Remove spurious brokenlinks 00004 require_once( "commandLine.inc" ); 00005 require_once( "./rebuildrecentchanges.inc" ); 00006 $wgTitle = Title::newFromText( "Rebuild brokenlinks script" ); 00007 00008 $wgDBuser = $wgDBadminuser; 00009 $wgDBpassword = $wgDBadminpassword; 00010 00011 00012 # That above is common code and should be hidden away :( 00013 00014 $n = 0; 00015 00016 echo "Checking for broken brokenlinks...\n"; 00017 00018 $sql = "SELECT cur_namespace,cur_title,cur_id FROM cur"; 00019 $res = wfQuery( $sql, DB_WRITE ); 00020 while( $s = wfFetchObject( $res ) ) { 00021 $n++; 00022 if(($n % 500) == 0) { 00023 echo "$n\n"; 00024 } 00025 $title = Title::makeTitle( $s->cur_namespace, $s->cur_title ); 00026 if($title) { 00027 $t = $title->getPrefixedDBKey(); 00028 $tt = wfStrencode( $t ); 00029 $any = false; 00030 $sql2 = "SELECT bl_from,cur_id,cur_namespace,cur_title FROM brokenlinks,cur WHERE bl_to='$tt' AND cur_id=bl_from"; 00031 $res2 = wfQuery( $sql2, DB_WRITE ); 00032 while( $s = wfFetchObject( $res2 ) ) { 00033 $from = Title::makeTitle( $s->cur_namespace, $s->cur_title ); 00034 $xt = $from->getPrefixedText(); 00035 echo "Found bad brokenlink to [[$t]] from page #$s->cur_id [[$xt]]!\n"; 00036 $any = true; 00037 } 00038 wfFreeResult( $res2 ); 00039 if($any) { 00040 echo "Removing brokenlinks to [[$t]]...\n"; 00041 $sql3 = "DELETE FROM brokenlinks WHERE bl_to='$tt'"; 00042 $res3 = wfQuery( $sql3, DB_WRITE ); 00043 #echo "-- $sql3\n"; 00044 } 00045 } else { 00046 echo "Illegal title?! Namespace $s->cur_namespace, title '$s->cur_title'\n"; 00047 } 00048 } 00049 echo "Done at $n.\n\n"; 00050 00051 echo "Clearing linkscc table...\n"; 00052 $sql4 = "DELETE FROM linkscc"; 00053 wfQuery( $sql4, DB_WRITE ); 00054 00055 ?>

Generated on Tue Jun 29 23:40:06 2004 for Mediawiki by doxygen 1.3.7