26require_once __DIR__ .
'/Maintenance.php';
40 parent::__construct();
41 $this->
addDescription(
'Cleans up tables that have valid usernames with no user ID' );
42 $this->
addOption(
'prefix',
'Interwiki prefix to apply to the usernames',
true,
true,
'p' );
43 $this->
addOption(
'table',
'Only clean up this table',
false,
true );
44 $this->
addOption(
'assign',
'Assign edits to existing local users if they exist',
false,
false );
53 $this->prefix = $this->
getOption(
'prefix' );
55 $this->assign = $this->
getOption(
'assign' );
58 'revision',
'rev_id',
'rev_user',
'rev_user_text',
59 [
'rev_user' => 0 ], [
'rev_timestamp',
'rev_id' ]
62 'archive',
'ar_id',
'ar_user',
'ar_user_text',
66 'logging',
'log_id',
'log_user',
'log_user_text',
67 [
'log_user' => 0 ], [
'log_timestamp',
'log_id' ]
70 'image',
'img_name',
'img_user',
'img_user_text',
71 [
'img_user' => 0 ], [
'img_timestamp',
'img_name' ]
74 'oldimage', [
'oi_name',
'oi_timestamp' ],
'oi_user',
'oi_user_text',
75 [], [
'oi_name',
'oi_timestamp' ]
78 'filearchive',
'fa_id',
'fa_user',
'fa_user_text',
82 'ipblocks',
'ipb_id',
'ipb_by',
'ipb_by_text',
86 'recentchanges',
'rc_id',
'rc_user',
'rc_user_text',
103 for ( $i = count( $indexFields ) - 1; $i >= 0; $i-- ) {
104 $field = $indexFields[$i];
105 $display[] = $field .
'=' . $row->$field;
106 $value = $dbw->addQuotes( $row->$field );
107 if ( $next ===
'' ) {
108 $next =
"$field > $value";
110 $next =
"$field > $value OR $field = $value AND ($next)";
113 $display = implode(
' ', array_reverse( $display ) );
114 return [ $next, $display ];
128 $table, $primaryKey, $idField, $nameField, array $conds, array $orderby
130 if ( $this->
table !==
null && $this->
table !== $table ) {
134 $primaryKey = (
array)$primaryKey;
135 $pkFilter = array_flip( $primaryKey );
137 "Beginning cleanup of $table\n"
148 array_merge( $primaryKey, [ $idField, $nameField ], $orderby ),
149 array_merge( $conds, [ $next ] ),
152 'ORDER BY' => $orderby,
153 'LIMIT' => $this->mBatchSize,
156 if ( !
$res->numRows() ) {
161 foreach (
$res as $row ) {
162 $name = $row->$nameField;
168 if ( $this->assign ) {
172 if ( !isset( $this->triedCreations[$name] ) ) {
173 $this->triedCreations[
$name] =
true;
174 if ( !Hooks::run(
'ImportHandleUnknownUser', [ $name ] ) ) {
181 $set = [ $idField => $id ];
182 $counter = &$countAssigned;
184 $set = [ $nameField => substr( $this->prefix .
'>' . $name, 0, 255 ) ];
185 $counter = &$countPrefixed;
191 array_intersect_key( (array)$row, $pkFilter ) + [
197 $counter += $dbw->affectedRows();
201 $this->
output(
"... $display\n" );
206 "Completed cleanup, assigned $countAssigned and prefixed $countPrefixed row(s)\n"
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Maintenance script that cleans up tables that have valid usernames with no user ID.
getUpdateKey()
Get the update key name to go in the update log table.
makeNextCond( $dbw, $indexFields, $row)
Calculate a "next" condition and progress display string.
cleanup( $table, $primaryKey, $idField, $nameField, array $conds, array $orderby)
Cleanup a table.
__construct()
Default constructor.
doDBUpdates()
Do the actual work.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
setBatchSize( $s=0)
Set the batch size.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
the array() calling protocol came about after MediaWiki 1.4rc1.
Allows to change the fields on the form that will be generated $name
require_once RUN_MAINTENANCE_IF_MAIN