X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Fremove-brokenlinks.php;h=a4a139ee39c5fdd8933cfdf6f14ada6258e7d63e;hb=5a72ae64e1b1bc31ef7763ee384ab59daee0cf10;hp=7faecef568dd86fadff3a29df33004e5acdc9994;hpb=2ba5e0e71834eb363242f73d0d0977ed6537fa9a;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/remove-brokenlinks.php b/maintenance/remove-brokenlinks.php index 7faecef568..a4a139ee39 100644 --- a/maintenance/remove-brokenlinks.php +++ b/maintenance/remove-brokenlinks.php @@ -1,23 +1,25 @@ tableNames( 'brokenlinks', 'cur', 'linkscc' ) ); + +$res = $dbw->select( 'cur', array( 'cur_namespace', 'cur_title', 'cur_id' ), false ); + +while( $s = $dbw->fetchObject( $res ) ) { $n++; if(($n % 500) == 0) { echo "$n\n"; @@ -25,21 +27,22 @@ while( $s = wfFetchObject( $res ) ) { $title = Title::makeTitle( $s->cur_namespace, $s->cur_title ); if($title) { $t = $title->getPrefixedDBKey(); - $tt = wfStrencode( $t ); + $tt = $dbw->strencode( $t ); $any = false; - $sql2 = "SELECT bl_from,cur_id,cur_namespace,cur_title FROM brokenlinks,cur WHERE bl_to='$tt' AND cur_id=bl_from"; - $res2 = wfQuery( $sql2, DB_WRITE ); - while( $s = wfFetchObject( $res2 ) ) { + $sql2 = "SELECT bl_from,cur_id,cur_namespace,cur_title FROM $brokenlinks,$cur " . + "WHERE bl_to='$tt' AND cur_id=bl_from"; + $res2 = $dbw->query( $sql2 ); + while( $s = $dbw->fetchObject( $res2 ) ) { $from = Title::makeTitle( $s->cur_namespace, $s->cur_title ); $xt = $from->getPrefixedText(); echo "Found bad brokenlink to [[$t]] from page #$s->cur_id [[$xt]]!\n"; $any = true; } - wfFreeResult( $res2 ); + $dbw->freeResult( $res2 ); if($any) { echo "Removing brokenlinks to [[$t]]...\n"; - $sql3 = "DELETE FROM brokenlinks WHERE bl_to='$tt'"; - $res3 = wfQuery( $sql3, DB_WRITE ); + $sql3 = "DELETE FROM $brokenlinks WHERE bl_to='$tt'"; + $res3 = $dbw->query( $sql3 ); #echo "-- $sql3\n"; } } else { @@ -49,7 +52,7 @@ while( $s = wfFetchObject( $res ) ) { echo "Done at $n.\n\n"; echo "Clearing linkscc table...\n"; -$sql4 = "DELETE FROM linkscc"; -wfQuery( $sql4, DB_WRITE ); +$sql4 = "DELETE FROM $linkscc"; +wfQuery( $sql4, DB_MASTER ); ?>