diff options
Diffstat (limited to 'maintenance/userDupes.inc')
-rw-r--r-- | maintenance/userDupes.inc | 67 |
1 files changed, 11 insertions, 56 deletions
diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index be45a111..8bd80c97 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -1,6 +1,6 @@ <?php /** - * Helper class for update.php and upgrade1_5.php. + * Helper class for update.php. * * Copyright © 2005 Brion Vibber <brion@pobox.com> * http://www.mediawiki.org/ @@ -112,9 +112,9 @@ class UserDupes { $count = count( $dupes ); $this->out( "Found $count accounts with duplicate records on " . wfWikiID() . ".\n" ); - $this->trimmed = 0; + $this->trimmed = 0; $this->reassigned = 0; - $this->failed = 0; + $this->failed = 0; foreach ( $dupes as $name ) { $this->examine( $name, $doDelete ); } @@ -158,11 +158,7 @@ class UserDupes { * @access private */ function lock() { - if ( $this->newSchema() ) { - $set = array( 'user', 'revision' ); - } else { - $set = array( 'user', 'cur', 'old' ); - } + $set = array( 'user', 'revision' ); $names = array_map( array( $this, 'lockTable' ), $set ); $tables = implode( ',', $names ); @@ -174,14 +170,6 @@ class UserDupes { } /** - * @return bool - * @access private - */ - function newSchema() { - return MWInit::classExists( 'Revision' ); - } - - /** * @access private */ function unlock() { @@ -223,7 +211,7 @@ class UserDupes { __METHOD__ ); $firstRow = $this->db->fetchObject( $result ); - $firstId = $firstRow->user_id; + $firstId = $firstRow->user_id; $this->out( "Record that will be used for '$name' is user_id=$firstId\n" ); foreach ( $result as $row ) { @@ -266,27 +254,10 @@ class UserDupes { * @access private */ function editCount( $userid ) { - if ( $this->newSchema() ) { - return $this->editCountOn( 'revision', 'rev_user', $userid ); - } else { - return $this->editCountOn( 'cur', 'cur_user', $userid ) + - $this->editCountOn( 'old', 'old_user', $userid ); - } - } - - /** - * Count the number of hits on a given table for this account. - * @param $table string - * @param $field string - * @param $userid int - * @return int - * @access private - */ - function editCountOn( $table, $field, $userid ) { return intval( $this->db->selectField( - $table, + 'revision', 'COUNT(*)', - array( $field => $userid ), + array( 'rev_user' => $userid ), __METHOD__ ) ); } @@ -296,26 +267,10 @@ class UserDupes { * @access private */ function reassignEdits( $from, $to ) { - $set = $this->newSchema() - ? array( 'revision' => 'rev_user' ) - : array( 'cur' => 'cur_user', 'old' => 'old_user' ); - foreach ( $set as $table => $field ) { - $this->reassignEditsOn( $table, $field, $from, $to ); - } - } - - /** - * @param $table string - * @param $field string - * @param $from int - * @param $to int - * @access private - */ - function reassignEditsOn( $table, $field, $from, $to ) { - $this->out( "reassigning on $table... " ); - $this->db->update( $table, - array( $field => $to ), - array( $field => $from ), + $this->out( 'reassigning... ' ); + $this->db->update( 'revision', + array( 'rev_user' => $to ), + array( 'rev_user' => $from ), __METHOD__ ); $this->out( "ok. " ); } |