dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Call resetServices() when setting globals in tests"
[lhc/web/wiklou.git]
/
maintenance
/
userDupes.inc
diff --git
a/maintenance/userDupes.inc
b/maintenance/userDupes.inc
index
257c6be
..
5f7f9d5
100644
(file)
--- a/
maintenance/userDupes.inc
+++ b/
maintenance/userDupes.inc
@@
-24,6
+24,8
@@
* @ingroup Maintenance
*/
* @ingroup Maintenance
*/
+use Wikimedia\Rdbms\IMaintainableDatabase;
+
/**
* Look for duplicate user table entries and optionally prune them.
*
/**
* Look for duplicate user table entries and optionally prune them.
*
@@
-33,13
+35,20
@@
* @ingroup Maintenance
*/
class UserDupes {
* @ingroup Maintenance
*/
class UserDupes {
+ /**
+ * @var IMaintainableDatabase
+ */
private $db;
private $reassigned;
private $trimmed;
private $failed;
private $outputCallback;
private $db;
private $reassigned;
private $trimmed;
private $failed;
private $outputCallback;
- function __construct( &$database, $outputCallback ) {
+ /**
+ * @param IMaintainableDatabase &$database
+ * @param callback $outputCallback
+ */
+ public function __construct( &$database, $outputCallback ) {
$this->db = $database;
$this->outputCallback = $outputCallback;
}
$this->db = $database;
$this->outputCallback = $outputCallback;
}
@@
-57,7
+66,7
@@
class UserDupes {
* user_name index applied.
* @return bool
*/
* user_name index applied.
* @return bool
*/
- function hasUniqueIndex() {
+
public
function hasUniqueIndex() {
$info = $this->db->indexInfo( 'user', 'user_name', __METHOD__ );
if ( !$info ) {
$this->out( "WARNING: doesn't seem to have user_name index at all!\n" );
$info = $this->db->indexInfo( 'user', 'user_name', __METHOD__ );
if ( !$info ) {
$this->out( "WARNING: doesn't seem to have user_name index at all!\n" );
@@
-82,7
+91,7
@@
class UserDupes {
*
* @return bool
*/
*
* @return bool
*/
- function clearDupes() {
+
public
function clearDupes() {
return $this->checkDupes( true );
}
return $this->checkDupes( true );
}
@@
-100,7
+109,7
@@
class UserDupes {
* from the database; false to just check.
* @return bool
*/
* from the database; false to just check.
* @return bool
*/
- function checkDupes( $doDelete = false ) {
+
private
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";
@@
-163,9
+172,8
@@
class UserDupes {
/**
* We don't want anybody to mess with our stuff...
/**
* We don't want anybody to mess with our stuff...
- * @private
*/
*/
- function lock() {
+
private
function lock() {
$set = [ 'user', 'revision' ];
$names = array_map( [ $this, 'lockTable' ], $set );
$tables = implode( ',', $names );
$set = [ 'user', 'revision' ];
$names = array_map( [ $this, 'lockTable' ], $set );
$tables = implode( ',', $names );
@@
-173,23
+181,22
@@
class UserDupes {
$this->db->query( "LOCK TABLES $tables", __METHOD__ );
}
$this->db->query( "LOCK TABLES $tables", __METHOD__ );
}
- function lockTable( $table ) {
+
private
function lockTable( $table ) {
return $this->db->tableName( $table ) . ' WRITE';
}
/**
* @private
*/
return $this->db->tableName( $table ) . ' WRITE';
}
/**
* @private
*/
- function unlock() {
+
private
function unlock() {
$this->db->query( "UNLOCK TABLES", __METHOD__ );
}
/**
* Grab usernames for which multiple records are present in the database.
* @return array
$this->db->query( "UNLOCK TABLES", __METHOD__ );
}
/**
* Grab usernames for which multiple records are present in the database.
* @return array
- * @private
*/
*/
- function getDupes() {
+
private
function getDupes() {
$user = $this->db->tableName( 'user' );
$result = $this->db->query(
"SELECT user_name,COUNT(*) AS n
$user = $this->db->tableName( 'user' );
$result = $this->db->query(
"SELECT user_name,COUNT(*) AS n
@@
-211,9
+218,8
@@
class UserDupes {
* for edits. If the dupes have no edits, we can safely remove them.
* @param string $name
* @param bool $doDelete
* for edits. If the dupes have no edits, we can safely remove them.
* @param string $name
* @param bool $doDelete
- * @private
*/
*/
- function examine( $name, $doDelete ) {
+
private
function examine( $name, $doDelete ) {
$result = $this->db->select( 'user',
[ 'user_id' ],
[ 'user_name' => $name ],
$result = $this->db->select( 'user',
[ 'user_id' ],
[ 'user_name' => $name ],
@@
-260,9
+266,8
@@
class UserDupes {
* where it might show up...
* @param int $userid
* @return int
* where it might show up...
* @param int $userid
* @return int
- * @private
*/
*/
- function editCount( $userid ) {
+
private
function editCount( $userid ) {
return intval( $this->db->selectField(
'revision',
'COUNT(*)',
return intval( $this->db->selectField(
'revision',
'COUNT(*)',
@@
-273,9
+278,8
@@
class UserDupes {
/**
* @param int $from
* @param int $to
/**
* @param int $from
* @param int $to
- * @private
*/
*/
- function reassignEdits( $from, $to ) {
+
private
function reassignEdits( $from, $to ) {
$this->out( 'reassigning... ' );
$this->db->update( 'revision',
[ 'rev_user' => $to ],
$this->out( 'reassigning... ' );
$this->db->update( 'revision',
[ 'rev_user' => $to ],
@@
-287,9
+291,8
@@
class UserDupes {
/**
* Remove a user account line.
* @param int $userid
/**
* Remove a user account line.
* @param int $userid
- * @private
*/
*/
- function trimAccount( $userid ) {
+
private
function trimAccount( $userid ) {
$this->out( "deleting..." );
$this->db->delete( 'user', [ 'user_id' => $userid ], __METHOD__ );
$this->out( " ok" );
$this->out( "deleting..." );
$this->db->delete( 'user', [ 'user_id' => $userid ], __METHOD__ );
$this->out( " ok" );