function hasUniqueIndex() {
$fname = 'UserDupes::hasUniqueIndex';
$info = $this->db->indexInfo( 'user', 'user_name', $fname );
- if( !$info ) {
+ if ( !$info ) {
wfOut( "WARNING: doesn't seem to have user_name index at all!\n" );
return false;
}
* @return bool
*/
function checkDupes( $doDelete = false ) {
- if( $this->hasUniqueIndex() ) {
- echo wfWikiID()." already has a unique index on its user table.\n";
+ if ( $this->hasUniqueIndex() ) {
+ echo wfWikiID() . " already has a unique index on its user table.\n";
return true;
}
$dupes = $this->getDupes();
$count = count( $dupes );
- wfOut( "Found $count accounts with duplicate records on ".wfWikiID().".\n" );
+ wfOut( "Found $count accounts with duplicate records on " . wfWikiID() . ".\n" );
$this->trimmed = 0;
$this->reassigned = 0;
$this->failed = 0;
- foreach( $dupes as $name ) {
+ foreach ( $dupes as $name ) {
$this->examine( $name, $doDelete );
}
wfOut( "\n" );
- if( $this->reassigned > 0 ) {
- if( $doDelete ) {
+ if ( $this->reassigned > 0 ) {
+ if ( $doDelete ) {
wfOut( "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n" );
} else {
wfOut( "$this->reassigned duplicate accounts need to have edits reassigned.\n" );
}
}
- if( $this->trimmed > 0 ) {
- if( $doDelete ) {
- wfOut( "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n" );
+ if ( $this->trimmed > 0 ) {
+ if ( $doDelete ) {
+ wfOut( "$this->trimmed duplicate user records were deleted from " . wfWikiID() . ".\n" );
} else {
- wfOut( "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n" );
+ wfOut( "$this->trimmed duplicate user accounts were found on " . wfWikiID() . " which can be removed safely.\n" );
}
}
- if( $this->failed > 0 ) {
+ if ( $this->failed > 0 ) {
wfOut( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" );
return false;
}
- if( $this->trimmed == 0 || $doDelete ) {
+ if ( $this->trimmed == 0 || $doDelete ) {
wfOut( "It is now safe to apply the unique index on user_name.\n" );
return true;
} else {
*/
function lock() {
$fname = 'UserDupes::lock';
- if( $this->newSchema() ) {
+ if ( $this->newSchema() ) {
$set = array( 'user', 'revision' );
} else {
$set = array( 'user', 'cur', 'old' );
HAVING n > 1", $fname );
$list = array();
- while( $row = $this->db->fetchObject( $result ) ) {
+ while ( $row = $this->db->fetchObject( $result ) ) {
$list[] = $row->user_name;
}
$this->db->freeResult( $result );
$firstId = $firstRow->user_id;
wfOut( "Record that will be used for '$name' is user_id=$firstId\n" );
- while( $row = $this->db->fetchObject( $result ) ) {
+ while ( $row = $this->db->fetchObject( $result ) ) {
$dupeId = $row->user_id;
wfOut( "... dupe id $dupeId: " );
$edits = $this->editCount( $dupeId );
- if( $edits > 0 ) {
+ if ( $edits > 0 ) {
$this->reassigned++;
wfOut( "has $edits edits! " );
- if( $doDelete ) {
+ if ( $doDelete ) {
$this->reassignEdits( $dupeId, $firstId );
$newEdits = $this->editCount( $dupeId );
- if( $newEdits == 0 ) {
+ if ( $newEdits == 0 ) {
wfOut( "confirmed cleaned. " );
} else {
$this->failed++;
wfOut( "ok, no edits. " );
}
$this->trimmed++;
- if( $doDelete ) {
+ if ( $doDelete ) {
$this->trimAccount( $dupeId );
}
wfOut( "\n" );
* @access private
*/
function editCount( $userid ) {
- if( $this->newSchema() ) {
+ if ( $this->newSchema() ) {
return $this->editCountOn( 'revision', 'rev_user', $userid );
} else {
return $this->editCountOn( 'cur', 'cur_user', $userid ) +
$set = $this->newSchema()
? array( 'revision' => 'rev_user' )
: array( 'cur' => 'cur_user', 'old' => 'old_user' );
- foreach( $set as $table => $field ) {
+ foreach ( $set as $table => $field ) {
$this->reassignEditsOn( $table, $field, $from, $to );
}
}