MediaWiki REL1_34
UserDupes Class Reference

Look for duplicate user table entries and optionally prune them. More...

Collaboration diagram for UserDupes:

Public Member Functions

 __construct (&$database, $outputCallback)
 
 clearDupes ()
 Checks the database for duplicate user account records and remove them in preparation for application of a unique index on the user_name field.
 
 hasUniqueIndex ()
 Check if this database's user table has already had a unique user_name index applied.
 

Private Member Functions

 checkDupes ( $doDelete=false)
 Checks the database for duplicate user account records in preparation for application of a unique index on the user_name field.
 
 editCount ( $userid)
 Count the number of edits attributed to this user.
 
 examine ( $name, $doDelete)
 Examine user records for the given name.
 
 getDupes ()
 Grab usernames for which multiple records are present in the database.
 
 lock ()
 We don't want anybody to mess with our stuff...
 
 lockTable ( $table)
 
 out ( $str)
 Output some text via the output callback provided.
 
 reassignEdits ( $from, $to)
 
 trimAccount ( $userid)
 Remove a user account line.
 
 unlock ()
 

Private Attributes

IMaintainableDatabase $db
 
 $failed
 
 $outputCallback
 
 $reassigned
 
 $trimmed
 

Detailed Description

Look for duplicate user table entries and optionally prune them.

This is still used by our MysqlUpdater at: includes/installer/MysqlUpdater.php

Definition at line 37 of file userDupes.inc.

Constructor & Destructor Documentation

◆ __construct()

UserDupes::__construct ( & $database,
$outputCallback )
Parameters
IMaintainableDatabase&$database
callback$outputCallback

Definition at line 51 of file userDupes.inc.

References $outputCallback.

Member Function Documentation

◆ checkDupes()

UserDupes::checkDupes ( $doDelete = false)
private

Checks the database for duplicate user account records in preparation for application of a unique index on the user_name field.

Returns true if the table is clean or if duplicates can be resolved automatically.

Returns false if there are duplicates and resolution was not requested. (If doing resolution, edits may be reassigned.) Status information will be echo'd to stdout.

Parameters
bool$doDeletePass true to actually remove things from the database; false to just check.
Returns
bool

Definition at line 112 of file userDupes.inc.

References examine(), getDupes(), hasUniqueIndex(), lock(), out(), and unlock().

Referenced by clearDupes().

◆ clearDupes()

UserDupes::clearDupes ( )

Checks the database for duplicate user account records and remove them in preparation for application of a unique index on the user_name field.

Returns true if the table is clean or if duplicates have been resolved automatically.

May return false if there are unresolvable problems. Status information will be echo'd to stdout.

Returns
bool

Definition at line 94 of file userDupes.inc.

References checkDupes().

◆ editCount()

UserDupes::editCount ( $userid)
private

Count the number of edits attributed to this user.

Does not currently check log table or other things where it might show up...

Parameters
int$userid
Returns
int

Definition at line 273 of file userDupes.inc.

Referenced by examine().

◆ examine()

UserDupes::examine ( $name,
$doDelete )
private

Examine user records for the given name.

Try to see which record will be the one that actually gets used, then check remaining records for edits. If the dupes have no edits, we can safely remove them.

Parameters
string$name
bool$doDelete

Definition at line 225 of file userDupes.inc.

References editCount(), out(), reassignEdits(), and trimAccount().

Referenced by checkDupes().

◆ getDupes()

UserDupes::getDupes ( )
private

Grab usernames for which multiple records are present in the database.

Returns
array

Definition at line 202 of file userDupes.inc.

Referenced by checkDupes().

◆ hasUniqueIndex()

UserDupes::hasUniqueIndex ( )

Check if this database's user table has already had a unique user_name index applied.

Returns
bool

Definition at line 69 of file userDupes.inc.

References out().

Referenced by checkDupes().

◆ lock()

UserDupes::lock ( )
private

We don't want anybody to mess with our stuff...

Definition at line 179 of file userDupes.inc.

Referenced by checkDupes().

◆ lockTable()

UserDupes::lockTable ( $table)
private

Definition at line 187 of file userDupes.inc.

◆ out()

UserDupes::out ( $str)
private

Output some text via the output callback provided.

Parameters
string$strText to print

Definition at line 60 of file userDupes.inc.

Referenced by checkDupes(), examine(), hasUniqueIndex(), reassignEdits(), and trimAccount().

◆ reassignEdits()

UserDupes::reassignEdits ( $from,
$to )
private
Parameters
int$from
int$to

Definition at line 285 of file userDupes.inc.

References out().

Referenced by examine().

◆ trimAccount()

UserDupes::trimAccount ( $userid)
private

Remove a user account line.

Parameters
int$userid

Definition at line 298 of file userDupes.inc.

References out().

Referenced by examine().

◆ unlock()

UserDupes::unlock ( )
private
Access:\n private

Definition at line 194 of file userDupes.inc.

Referenced by checkDupes().

Member Data Documentation

◆ $db

IMaintainableDatabase UserDupes::$db
private

Definition at line 41 of file userDupes.inc.

◆ $failed

UserDupes::$failed
private

Definition at line 44 of file userDupes.inc.

◆ $outputCallback

UserDupes::$outputCallback
private

Definition at line 45 of file userDupes.inc.

Referenced by __construct().

◆ $reassigned

UserDupes::$reassigned
private

Definition at line 42 of file userDupes.inc.

◆ $trimmed

UserDupes::$trimmed
private

Definition at line 43 of file userDupes.inc.


The documentation for this class was generated from the following file: