$info = $this->db->indexInfo( 'user', 'user_name', __METHOD__ );
if ( !$info ) {
$this->out( "WARNING: doesn't seem to have user_name index at all!\n" );
+
return false;
}
function checkDupes( $doDelete = false ) {
if ( $this->hasUniqueIndex() ) {
echo wfWikiID() . " already has a unique index on its user table.\n";
+
return true;
}
if ( $this->reassigned > 0 ) {
if ( $doDelete ) {
- $this->out( "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n" );
+ $this->out( "$this->reassigned duplicate accounts had edits "
+ . "reassigned to a canonical record id.\n" );
} else {
$this->out( "$this->reassigned duplicate accounts need to have edits reassigned.\n" );
}
if ( $this->trimmed > 0 ) {
if ( $doDelete ) {
- $this->out( "$this->trimmed duplicate user records were deleted from " . wfWikiID() . ".\n" );
+ $this->out( "$this->trimmed duplicate user records were deleted from "
+ . wfWikiID() . ".\n" );
} else {
- $this->out( "$this->trimmed duplicate user accounts were found on " . wfWikiID() . " which can be removed safely.\n" );
+ $this->out( "$this->trimmed duplicate user accounts were found on "
+ . wfWikiID() . " which can be removed safely.\n" );
}
}
if ( $this->failed > 0 ) {
$this->out( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" );
+
return false;
}
if ( $this->trimmed == 0 || $doDelete ) {
$this->out( "It is now safe to apply the unique index on user_name.\n" );
+
return true;
} else {
$this->out( "Run this script again with the --fix option to automatically delete them.\n" );
+
return false;
}
}
* @access private
*/
function lock() {
- $set = array( 'user', 'revision' );
- $names = array_map( array( $this, 'lockTable' ), $set );
+ $set = [ 'user', 'revision' ];
+ $names = array_map( [ $this, 'lockTable' ], $set );
$tables = implode( ',', $names );
$this->db->query( "LOCK TABLES $tables", __METHOD__ );
GROUP BY user_name
HAVING n > 1", __METHOD__ );
- $list = array();
+ $list = [];
foreach ( $result as $row ) {
$list[] = $row->user_name;
}
+
return $list;
}
*/
function examine( $name, $doDelete ) {
$result = $this->db->select( 'user',
- array( 'user_id' ),
- array( 'user_name' => $name ),
+ [ 'user_id' ],
+ [ 'user_name' => $name ],
__METHOD__ );
$firstRow = $this->db->fetchObject( $result );
return intval( $this->db->selectField(
'revision',
'COUNT(*)',
- array( 'rev_user' => $userid ),
+ [ 'rev_user' => $userid ],
__METHOD__ ) );
}
function reassignEdits( $from, $to ) {
$this->out( 'reassigning... ' );
$this->db->update( 'revision',
- array( 'rev_user' => $to ),
- array( 'rev_user' => $from ),
+ [ 'rev_user' => $to ],
+ [ 'rev_user' => $from ],
__METHOD__ );
$this->out( "ok. " );
}
*/
function trimAccount( $userid ) {
$this->out( "deleting..." );
- $this->db->delete( 'user', array( 'user_id' => $userid ), __METHOD__ );
+ $this->db->delete( 'user', [ 'user_id' => $userid ], __METHOD__ );
$this->out( " ok" );
}
-
}