X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FuserDupes.inc;h=69c926584e376d064b2c25b4eccb9ca809775d47;hb=fe94275c8fcfc248a5eae857dde7c5772d993ab5;hp=bc8fbcfad16b49f4a900509b8d3ba6bb4cef3bec;hpb=7ee1504a9a34067fd5b3e1fc315ccaa99661cb44;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index bc8fbcfad1..69c926584e 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -61,6 +61,7 @@ class UserDupes { $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; } @@ -102,6 +103,7 @@ class UserDupes { function checkDupes( $doDelete = false ) { if ( $this->hasUniqueIndex() ) { echo wfWikiID() . " already has a unique index on its user table.\n"; + return true; } @@ -144,14 +146,17 @@ class UserDupes { 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; } } @@ -161,8 +166,8 @@ class UserDupes { * @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__ ); @@ -190,12 +195,13 @@ class UserDupes { "SELECT user_name,COUNT(*) AS n FROM $user GROUP BY user_name - HAVING n > 1", __METHOD__ ); + HAVING n > 1", __METHOD__ ); - $list = array(); + $list = []; foreach ( $result as $row ) { $list[] = $row->user_name; } + return $list; } @@ -209,8 +215,8 @@ class UserDupes { */ 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 ); @@ -260,7 +266,7 @@ class UserDupes { return intval( $this->db->selectField( 'revision', 'COUNT(*)', - array( 'rev_user' => $userid ), + [ 'rev_user' => $userid ], __METHOD__ ) ); } @@ -272,8 +278,8 @@ class UserDupes { 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. " ); } @@ -285,8 +291,7 @@ class UserDupes { */ 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" ); } - }