r9393 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9392‎ | r9393 | r9394 >
Date:10:55, 11 June 2005
Author:vibber
Status:old
Tags:
Comment:
* Enhance cleanupDupes.php to save the pruned revisions to old for safety,
and to try to pick the same one that would be read by the wiki
Modified paths:
  • /branches/REL1_4/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_4/phase3/maintenance/cleanupDupes.php (modified) (history)

Diff [purge]

Index: branches/REL1_4/phase3/maintenance/cleanupDupes.php
@@ -35,7 +35,8 @@
3636 function fixDupes( $fixthem = false) {
3737 $dbw =& wfGetDB( DB_MASTER );
3838 $cur = $dbw->tableName( 'cur' );
39 - $dbw->query( "LOCK TABLES $cur WRITE" );
 39+ $old = $dbw->tableName( 'old' );
 40+ $dbw->query( "LOCK TABLES $cur WRITE, $old WRITE" );
4041 echo "Checking for duplicate cur table entries... (this may take a while on a large wiki)\n";
4142 $res = $dbw->query( <<<END
4243 SELECT cur_namespace,cur_title,count(*) as c,min(cur_id) as id
@@ -55,15 +56,56 @@
5657 while( $row = $dbw->fetchObject( $res ) ) {
5758 $ns = IntVal( $row->cur_namespace );
5859 $title = $dbw->addQuotes( $row->cur_title );
59 - $id = IntVal( $row->id );
 60+
 61+ # Get the first responding ID; that'll be the one we keep.
 62+ $id = $dbw->selectField( 'cur', 'cur_id', array(
 63+ 'cur_namespace' => $row->cur_namespace,
 64+ 'cur_title' => $row->cur_title ) );
 65+
6066 echo "$ns:$row->cur_title (canonical ID $id)\n";
 67+ if( $id != $row->id ) {
 68+ echo " ** minimum ID $row->id; ";
 69+ $timeMin = $dbw->selectField( 'cur', 'cur_timestamp', array(
 70+ 'cur_id' => $row->id ) );
 71+ $timeFirst = $dbw->selectField( 'cur', 'cur_timestamp', array(
 72+ 'cur_id' => $id ) );
 73+ if( $timeMin == $timeFirst ) {
 74+ echo "timestamps match at $timeFirst; ok\n";
 75+ } else {
 76+ echo "timestamps don't match! min: $timeMin, first: $timeFirst; ";
 77+ if( $timeMin > $timeFirst ) {
 78+ $id = $row->id;
 79+ echo "keeping minimum: $id\n";
 80+ } else {
 81+ echo "keeping first: $id\n";
 82+ }
 83+ }
 84+ }
 85+
6186 if( $fixthem ) {
6287 $dbw->query( <<<END
 88+INSERT
 89+ INTO $old
 90+ (old_namespace, old_title, old_text,
 91+ old_comment, old_user, old_user_text,
 92+ old_timestamp, old_minor_edit, old_flags,
 93+ inverse_timestamp)
 94+SELECT cur_namespace, cur_title, cur_text,
 95+ cur_comment, cur_user, cur_user_text,
 96+ cur_timestamp, cur_minor_edit, '',
 97+ inverse_timestamp
 98+ FROM $cur
 99+ WHERE cur_namespace=$ns
 100+ AND cur_title=$title
 101+ AND cur_id != $id
 102+END
 103+ );
 104+ $dbw->query( <<<END
63105 DELETE
64106 FROM $cur
65107 WHERE cur_namespace=$ns
66108 AND cur_title=$title
67 - AND cur_id>$id
 109+ AND cur_id != $id
68110 END
69111 );
70112 }
Index: branches/REL1_4/phase3/RELEASE-NOTES
@@ -650,6 +650,8 @@
651651 * (bug 2355) Use content language in image blacklist check
652652 * (bug 2368) Avoid fatally breaking PHP 4.1.2 in a debug line
653653 * (bug 2384) Fix typo in regex for IP address checking
 654+* Enhance cleanupDupes.php to save the pruned revisions to old for safety, and
 655+ to try to pick the same one that would be read by the wiki
654656
655657
656658 === Caveats ===

Status & tagging log