Go to the documentation of this file.
107 $this->checkIfUserExists =
true;
109 if ( isset(
$options[
'checkIfUserExists'] ) ) {
110 $this->checkIfUserExists =
$options[
'checkIfUserExists'];
113 if ( isset(
$options[
'debugPrefix'] ) ) {
114 $this->debugPrefix =
$options[
'debugPrefix'];
117 if ( isset(
$options[
'reason'] ) ) {
122 $this->tablesJob = [];
127 $this->
tables[
'image'] = [
'img_user_text',
'img_user' ];
128 $this->
tables[
'oldimage'] = [
'oi_user_text',
'oi_user' ];
129 $this->
tables[
'filearchive'] = [
'fa_user_text',
'fa_user' ];
134 $this->tablesJob[
'revision'] = [
135 self::NAME_COL =>
'rev_user_text',
136 self::UID_COL =>
'rev_user',
137 self::TIME_COL =>
'rev_timestamp',
138 'uniqueKey' =>
'rev_id'
140 $this->tablesJob[
'archive'] = [
141 self::NAME_COL =>
'ar_user_text',
142 self::UID_COL =>
'ar_user',
143 self::TIME_COL =>
'ar_timestamp',
144 'uniqueKey' =>
'ar_id'
146 $this->tablesJob[
'logging'] = [
147 self::NAME_COL =>
'log_user_text',
148 self::UID_COL =>
'log_user',
149 self::TIME_COL =>
'log_timestamp',
150 'uniqueKey' =>
'log_id'
153 $this->
tables[
'revision'] = [
'rev_user_text',
'rev_user' ];
154 $this->
tables[
'archive'] = [
'ar_user_text',
'ar_user' ];
155 $this->
tables[
'logging'] = [
'log_user_text',
'log_user' ];
159 $this->tablesJob[
'recentchanges'] = [
'rc_user_text',
'rc_user',
'rc_timestamp' ];
161 $this->
tables[
'recentchanges'] = [
'rc_user_text',
'rc_user' ];
169 if ( $this->debugPrefix ) {
170 $msg =
"{$this->debugPrefix}: $msg";
186 $dbw->startAtomic( __METHOD__ );
188 Hooks::run(
'RenameUserPreRename', [ $this->uid, $this->old, $this->
new ] );
191 if ( $this->checkIfUserExists && !self::lockUserAndGetId( $this->old ) ) {
192 $this->
debug(
"User {$this->old} does not exist, bailing out" );
199 $this->
debug(
"Starting rename of {$this->old} to {$this->new}" );
200 $dbw->update(
'user',
201 [
'user_name' => $this->
new,
'user_touched' => $dbw->timestamp() ],
206 $dbw->update(
'actor',
207 [
'actor_name' => $this->
new ],
208 [
'actor_name' => $this->old,
'actor_user' => $this->uid ],
218 is_callable( [ SessionManager::singleton(),
'invalidateSessionsForUser' ] )
220 $user->load( User::READ_LATEST );
221 SessionManager::singleton()->invalidateSessionsForUser(
$user );
224 $authUser->resetAuthToken();
228 $user->invalidateCache();
231 $dbw->update(
'ipblocks',
232 [
'ipb_address' => $this->
new ],
233 [
'ipb_user' => $this->uid,
'ipb_address' => $this->old ],
241 $this->
debug(
"Updating logging table for {$this->old} to {$this->new}" );
245 $dbw->update(
'logging',
246 [
'log_title' => $newTitle->getDBkey() ],
247 [
'log_type' => $logTypesOnUser,
254 foreach ( $this->
tables as $table => $fieldSet ) {
255 list( $nameCol, $userCol ) = $fieldSet;
256 $dbw->update( $table,
257 [ $nameCol => $this->
new ],
258 [ $nameCol => $this->old, $userCol => $this->uid ],
272 foreach ( $this->tablesJob
as $table =>
$params ) {
277 $res = $dbw->select( $table,
279 [ $userTextC => $this->old, $userIDC => $this->uid ],
281 [
'ORDER BY' =>
"$timestampC ASC" ]
285 $jobParams[
'table'] = $table;
286 $jobParams[
'column'] = $userTextC;
287 $jobParams[
'uidColumn'] = $userIDC;
288 $jobParams[
'timestampColumn'] = $timestampC;
293 $jobParams[
'minTimestamp'] =
'0';
294 $jobParams[
'maxTimestamp'] =
'0';
295 $jobParams[
'count'] = 0;
297 if ( isset(
$params[
'uniqueKey'] ) ) {
298 $jobParams[
'uniqueKey'] =
$params[
'uniqueKey'];
303 $row = $dbw->fetchObject(
$res );
305 # If there are any job rows left, add it to the queue as one job
306 if ( $jobParams[
'count'] > 0 ) {
311 # Since the ORDER BY is ASC, set the min timestamp with first row
312 if ( $jobParams[
'count'] === 0 ) {
313 $jobParams[
'minTimestamp'] = $row->$timestampC;
315 # Keep updating the last timestamp, so it should be correct
316 # when the last item is added.
317 $jobParams[
'maxTimestamp'] = $row->$timestampC;
319 $jobParams[
'count']++;
320 # Once a job has $wgUpdateRowsPerJob rows, add it to the queue
323 $jobParams[
'minTimestamp'] =
'0';
324 $jobParams[
'maxTimestamp'] =
'0';
325 $jobParams[
'count'] = 0;
328 $dbw->freeResult(
$res );
333 $logEntry->setPerformer( $this->renamer );
335 $logEntry->setComment( $this->
reason );
336 $logEntry->setParameters( [
337 '4::olduser' => $this->old,
338 '5::newuser' => $this->
new,
339 '6::edits' => $contribs
341 $logid = $logEntry->insert();
343 foreach ( $jobs
as $job ) {
344 $job->params[
'logId'] = $logid;
350 $count =
count( $jobs );
353 $this->
debug(
"Queued $count jobs for {$this->old} to {$this->new}" );
357 $dbw->endAtomic( __METHOD__ );
361 $dbw->onTransactionIdle(
function ()
use ( $that, $dbw, $logEntry, $logid,
$fname ) {
362 $dbw->startAtomic(
$fname );
365 $user->load( User::READ_LATEST );
368 AuthManager::callLegacyAuthPlugin(
'updateExternalDB', [
$user ] );
375 $user->saveSettings();
376 Hooks::run(
'RenameUserComplete', [ $that->uid, $that->old, $that->new ] );
378 $logEntry->publish( $logid );
379 $dbw->endAtomic(
$fname );
382 $this->
debug(
"Finished rename for {$this->old} to {$this->new}" );
395 [
'user_name' =>
$name ],
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
string $new
The new username.
static newFromId( $id)
Static factory method for creation from a given user ID.
In both all secondary updates will be triggered handle like object that caches derived data representing a and can trigger updates of cached copies of that e g in the links tables
bool $checkIfUserExists
Flag that can be set to false, in case another process has already started the updates and the old us...
static getActorMigrationStage()
Fetch the core actor table schema migration stage.
rename()
Do the rename operation.
wfQueriesMustScale()
Should low-performance queries be disabled?
const MIGRATION_WRITE_BOTH
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
__construct( $old, $new, $uid, User $renamer, $options=[])
Constructor.
array $tables
The tables => fields to be updated.
User $renamer
User object of the user performing the rename, for logging purposes.
static factory( $command, Title $title, $params=[])
Create the appropriate object to handle a specific job.
Class which performs the actual renaming of users.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static getLogTypesOnUser()
List log type for which the target is a user Thus if the given target is in NS_MAIN we can alter it t...
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
$wgUpdateRowsPerJob
Number of rows to update per job.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
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
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Allows to change the fields on the form that will be generated $name
array $tablesJob
tables => fields to be updated in a deferred job
const CONTRIB_JOB
Users with more than this number of edits will have their rename operation deferred via the job queue...
string $debugPrefix
A prefix to use in all debug log messages.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is and will automatically terminate your rights under this License parties who have received or from you under this License will not have their licenses terminated so long as such parties remain in full compliance You are not required to accept this since you have not signed it nothing else grants you permission to modify or distribute the Program or its derivative works These actions are prohibited by law if you do not accept this License by modifying or distributing the you indicate your acceptance of this License to do and all its terms and conditions for distributing or modifying the Program or works based on it Each time you redistribute the the recipient automatically receives a license from the original licensor to distribute or modify the Program subject to these terms and conditions You may not impose any further restrictions on the recipients exercise of the rights granted herein You are not responsible for enforcing compliance by third parties to this License as a consequence of a court judgment or allegation of patent infringement or for any other reason(not limited to patent issues)
string $old
The old username.
static singleton( $domain=false)
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
string $reason
Reason to be used in the log entry.
if(count( $args)< 1) $job
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Class for creating new log entries and inserting them into the database.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
$wgAuth $wgAuth
Authentication plugin.
static lockUserAndGetId( $name)
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.