2023-02-28 05:51:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\RenameUser;
|
|
|
|
|
|
2023-03-01 03:20:34 +00:00
|
|
|
use JobQueueGroup;
|
2023-03-09 23:52:40 +00:00
|
|
|
use JobSpecification;
|
2023-02-28 05:51:43 +00:00
|
|
|
use ManualLogEntry;
|
|
|
|
|
use MediaWiki\HookContainer\HookRunner;
|
2023-03-01 03:20:34 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
|
|
|
|
use MediaWiki\MainConfigNames;
|
2023-02-28 05:51:43 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
use MediaWiki\Session\SessionManager;
|
2023-05-03 19:50:13 +00:00
|
|
|
use MediaWiki\Specials\SpecialLog;
|
2023-03-01 03:20:34 +00:00
|
|
|
use MediaWiki\Title\TitleFactory;
|
2023-09-19 12:13:45 +00:00
|
|
|
use MediaWiki\User\User;
|
2023-03-01 03:20:34 +00:00
|
|
|
use MediaWiki\User\UserFactory;
|
|
|
|
|
use Psr\Log\LoggerInterface;
|
2023-10-31 12:58:13 +00:00
|
|
|
use Wikimedia\Rdbms\IConnectionProvider;
|
2024-09-27 16:12:27 +00:00
|
|
|
use Wikimedia\Rdbms\IDBAccessObject;
|
2023-09-19 11:06:53 +00:00
|
|
|
use Wikimedia\Rdbms\SelectQueryBuilder;
|
2023-02-28 05:51:43 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class which performs the actual renaming of users
|
|
|
|
|
*/
|
|
|
|
|
class RenameuserSQL {
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* The old username of the user being renamed
|
2023-02-28 05:51:43 +00:00
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
public $old;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* The new username of the user being renamed
|
2023-02-28 05:51:43 +00:00
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
public $new;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* The user ID of the user being renamed
|
2023-02-28 05:51:43 +00:00
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
public $uid;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* The [ tables => fields ] to be updated
|
2023-02-28 05:51:43 +00:00
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public $tables;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* [ tables => fields ] to be updated in a deferred job
|
2023-02-28 05:51:43 +00:00
|
|
|
*
|
|
|
|
|
* @var array[]
|
|
|
|
|
*/
|
|
|
|
|
public $tablesJob;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Flag that can be set to false, in case another process has already started
|
|
|
|
|
* the updates and the old username may have already been renamed in the user table.
|
|
|
|
|
*
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
public $checkIfUserExists;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User object of the user performing the rename, for logging purposes
|
|
|
|
|
*
|
|
|
|
|
* @var User
|
|
|
|
|
*/
|
|
|
|
|
private $renamer;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* Reason for the rename to be used in the log entry
|
2023-02-28 05:51:43 +00:00
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
private $reason = '';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A prefix to use in all debug log messages
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
private $debugPrefix = '';
|
|
|
|
|
|
|
|
|
|
// B/C constants for tablesJob field
|
|
|
|
|
public const NAME_COL = 0;
|
|
|
|
|
public const UID_COL = 1;
|
|
|
|
|
public const TIME_COL = 2;
|
|
|
|
|
|
|
|
|
|
/** @var HookRunner */
|
|
|
|
|
private $hookRunner;
|
|
|
|
|
|
2023-10-31 12:58:13 +00:00
|
|
|
/** @var IConnectionProvider */
|
|
|
|
|
private $dbProvider;
|
2023-03-01 03:20:34 +00:00
|
|
|
|
|
|
|
|
/** @var UserFactory */
|
|
|
|
|
private $userFactory;
|
|
|
|
|
|
|
|
|
|
/** @var JobQueueGroup */
|
|
|
|
|
private $jobQueueGroup;
|
|
|
|
|
|
|
|
|
|
/** @var TitleFactory */
|
|
|
|
|
private $titleFactory;
|
|
|
|
|
|
|
|
|
|
/** @var LoggerInterface */
|
|
|
|
|
private $logger;
|
|
|
|
|
|
|
|
|
|
/** @var int */
|
|
|
|
|
private $updateRowsPerJob;
|
|
|
|
|
|
2023-02-28 05:51:43 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*
|
|
|
|
|
* @param string $old The old username
|
|
|
|
|
* @param string $new The new username
|
|
|
|
|
* @param int $uid
|
|
|
|
|
* @param User $renamer
|
|
|
|
|
* @param array $options Optional extra options.
|
|
|
|
|
* 'reason' - string, reason for the rename
|
|
|
|
|
* 'debugPrefix' - string, prefixed to debug messages
|
|
|
|
|
* 'checkIfUserExists' - bool, whether to update the user table
|
|
|
|
|
*/
|
|
|
|
|
public function __construct( $old, $new, $uid, User $renamer, $options = [] ) {
|
2023-03-01 03:20:34 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$this->hookRunner = new HookRunner( $services->getHookContainer() );
|
2024-01-22 21:32:48 +00:00
|
|
|
$this->dbProvider = $services->getConnectionProvider();
|
2023-03-01 03:20:34 +00:00
|
|
|
$this->userFactory = $services->getUserFactory();
|
|
|
|
|
$this->jobQueueGroup = $services->getJobQueueGroup();
|
|
|
|
|
$this->titleFactory = $services->getTitleFactory();
|
|
|
|
|
$this->logger = LoggerFactory::getInstance( 'Renameuser' );
|
2023-02-28 05:51:43 +00:00
|
|
|
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
$this->updateRowsPerJob = $config->get( MainConfigNames::UpdateRowsPerJob );
|
|
|
|
|
|
2023-02-28 05:51:43 +00:00
|
|
|
$this->old = $old;
|
|
|
|
|
$this->new = $new;
|
|
|
|
|
$this->uid = $uid;
|
|
|
|
|
$this->renamer = $renamer;
|
|
|
|
|
$this->checkIfUserExists = true;
|
|
|
|
|
|
|
|
|
|
if ( isset( $options['checkIfUserExists'] ) ) {
|
|
|
|
|
$this->checkIfUserExists = $options['checkIfUserExists'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $options['debugPrefix'] ) ) {
|
|
|
|
|
$this->debugPrefix = $options['debugPrefix'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $options['reason'] ) ) {
|
|
|
|
|
$this->reason = $options['reason'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->tables = []; // Immediate updates
|
|
|
|
|
$this->tablesJob = []; // Slow updates
|
|
|
|
|
|
|
|
|
|
$this->hookRunner->onRenameUserSQL( $this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function debug( $msg ) {
|
|
|
|
|
if ( $this->debugPrefix ) {
|
|
|
|
|
$msg = "{$this->debugPrefix}: $msg";
|
|
|
|
|
}
|
2023-03-01 03:20:34 +00:00
|
|
|
$this->logger->debug( $msg );
|
2023-02-28 05:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Do the rename operation
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function rename() {
|
2023-10-31 12:58:13 +00:00
|
|
|
$dbw = $this->dbProvider->getPrimaryDatabase();
|
2023-02-28 05:51:43 +00:00
|
|
|
$atomicId = $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
|
|
|
|
|
|
|
|
|
|
$this->hookRunner->onRenameUserPreRename( $this->uid, $this->old, $this->new );
|
|
|
|
|
|
|
|
|
|
// Make sure the user exists if needed
|
2023-03-01 03:20:34 +00:00
|
|
|
if ( $this->checkIfUserExists && !$this->lockUserAndGetId( $this->old ) ) {
|
2023-02-28 05:51:43 +00:00
|
|
|
$this->debug( "User {$this->old} does not exist, bailing out" );
|
|
|
|
|
$dbw->cancelAtomic( __METHOD__, $atomicId );
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-07 19:14:31 +00:00
|
|
|
// Grab the user's edit count before any updates are made; used later in a log entry
|
|
|
|
|
$contribs = $this->userFactory->newFromId( $this->uid )->getEditCount();
|
|
|
|
|
|
2023-02-28 05:51:43 +00:00
|
|
|
// Rename and touch the user before re-attributing edits to avoid users still being
|
|
|
|
|
// logged in and making new edits (under the old name) while being renamed.
|
|
|
|
|
$this->debug( "Starting rename of {$this->old} to {$this->new}" );
|
2023-04-21 08:49:50 +00:00
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( 'user' )
|
|
|
|
|
->set( [ 'user_name' => $this->new, 'user_touched' => $dbw->timestamp() ] )
|
|
|
|
|
->where( [ 'user_name' => $this->old, 'user_id' => $this->uid ] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
|
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( 'actor' )
|
|
|
|
|
->set( [ 'actor_name' => $this->new ] )
|
|
|
|
|
->where( [ 'actor_name' => $this->old, 'actor_user' => $this->uid ] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
2023-02-28 05:51:43 +00:00
|
|
|
|
|
|
|
|
// Reset token to break login with central auth systems.
|
|
|
|
|
// Again, avoids user being logged in with old name.
|
2023-03-01 03:20:34 +00:00
|
|
|
$user = $this->userFactory->newFromId( $this->uid );
|
2023-02-28 05:51:43 +00:00
|
|
|
|
2024-01-23 14:01:06 +00:00
|
|
|
$user->load( IDBAccessObject::READ_LATEST );
|
2023-02-28 05:51:43 +00:00
|
|
|
SessionManager::singleton()->invalidateSessionsForUser( $user );
|
|
|
|
|
|
|
|
|
|
// Purge user cache
|
|
|
|
|
$user->invalidateCache();
|
|
|
|
|
|
2024-04-09 03:26:02 +00:00
|
|
|
// Update the block_target table rows if this user has a block in there.
|
|
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( 'block_target' )
|
|
|
|
|
->set( [ 'bt_user_text' => $this->new ] )
|
|
|
|
|
->where( [ 'bt_user' => $this->uid, 'bt_user_text' => $this->old ] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
2023-04-21 08:49:50 +00:00
|
|
|
|
2023-02-28 05:51:43 +00:00
|
|
|
// Update this users block/rights log. Ideally, the logs would be historical,
|
|
|
|
|
// but it is really annoying when users have "clean" block logs by virtue of
|
|
|
|
|
// being renamed, which makes admin tasks more of a pain...
|
2023-03-01 03:20:34 +00:00
|
|
|
$oldTitle = $this->titleFactory->makeTitle( NS_USER, $this->old );
|
|
|
|
|
$newTitle = $this->titleFactory->makeTitle( NS_USER, $this->new );
|
2023-02-28 05:51:43 +00:00
|
|
|
$this->debug( "Updating logging table for {$this->old} to {$this->new}" );
|
|
|
|
|
|
|
|
|
|
// Exclude user renames per T200731
|
|
|
|
|
$logTypesOnUser = array_diff( SpecialLog::getLogTypesOnUser(), [ 'renameuser' ] );
|
|
|
|
|
|
2023-04-21 08:49:50 +00:00
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( 'logging' )
|
|
|
|
|
->set( [ 'log_title' => $newTitle->getDBkey() ] )
|
|
|
|
|
->where( [
|
2023-02-28 05:51:43 +00:00
|
|
|
'log_type' => $logTypesOnUser,
|
|
|
|
|
'log_namespace' => NS_USER,
|
|
|
|
|
'log_title' => $oldTitle->getDBkey()
|
2023-04-21 08:49:50 +00:00
|
|
|
] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
2023-02-28 05:51:43 +00:00
|
|
|
|
2023-10-07 19:14:31 +00:00
|
|
|
$this->debug( "Updating recentchanges table for rename from {$this->old} to {$this->new}" );
|
2023-04-21 08:49:50 +00:00
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( 'recentchanges' )
|
|
|
|
|
->set( [ 'rc_title' => $newTitle->getDBkey() ] )
|
|
|
|
|
->where( [
|
2023-02-28 05:51:43 +00:00
|
|
|
'rc_type' => RC_LOG,
|
|
|
|
|
'rc_log_type' => $logTypesOnUser,
|
|
|
|
|
'rc_namespace' => NS_USER,
|
|
|
|
|
'rc_title' => $oldTitle->getDBkey()
|
2023-04-21 08:49:50 +00:00
|
|
|
] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
2023-02-28 05:51:43 +00:00
|
|
|
|
|
|
|
|
// Do immediate re-attribution table updates...
|
|
|
|
|
foreach ( $this->tables as $table => $fieldSet ) {
|
2023-09-19 11:06:53 +00:00
|
|
|
[ $nameCol, $userCol ] = $fieldSet;
|
2023-04-21 08:49:50 +00:00
|
|
|
$dbw->newUpdateQueryBuilder()
|
|
|
|
|
->update( $table )
|
|
|
|
|
->set( [ $nameCol => $this->new ] )
|
|
|
|
|
->where( [ $nameCol => $this->old, $userCol => $this->uid ] )
|
|
|
|
|
->caller( __METHOD__ )->execute();
|
2023-02-28 05:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @var RenameUserJob[] $jobs */
|
|
|
|
|
$jobs = []; // jobs for all tables
|
|
|
|
|
// Construct jobqueue updates...
|
|
|
|
|
// FIXME: if a bureaucrat renames a user in error, he/she
|
|
|
|
|
// must be careful to wait until the rename finishes before
|
|
|
|
|
// renaming back. This is due to the fact the job "queue"
|
|
|
|
|
// is not really FIFO, so we might end up with a bunch of edits
|
|
|
|
|
// randomly mixed between the two new names. Some sort of rename
|
|
|
|
|
// lock might be in order...
|
|
|
|
|
foreach ( $this->tablesJob as $table => $params ) {
|
|
|
|
|
$userTextC = $params[self::NAME_COL]; // some *_user_text column
|
|
|
|
|
$userIDC = $params[self::UID_COL]; // some *_user column
|
|
|
|
|
$timestampC = $params[self::TIME_COL]; // some *_timestamp column
|
|
|
|
|
|
2023-09-19 11:06:53 +00:00
|
|
|
$res = $dbw->newSelectQueryBuilder()
|
|
|
|
|
->select( [ $timestampC ] )
|
|
|
|
|
->from( $table )
|
|
|
|
|
->where( [ $userTextC => $this->old, $userIDC => $this->uid ] )
|
|
|
|
|
->orderBy( $timestampC, SelectQueryBuilder::SORT_ASC )
|
|
|
|
|
->caller( __METHOD__ )->fetchResultSet();
|
2023-02-28 05:51:43 +00:00
|
|
|
|
|
|
|
|
$jobParams = [];
|
|
|
|
|
$jobParams['table'] = $table;
|
|
|
|
|
$jobParams['column'] = $userTextC;
|
|
|
|
|
$jobParams['uidColumn'] = $userIDC;
|
|
|
|
|
$jobParams['timestampColumn'] = $timestampC;
|
|
|
|
|
$jobParams['oldname'] = $this->old;
|
|
|
|
|
$jobParams['newname'] = $this->new;
|
|
|
|
|
$jobParams['userID'] = $this->uid;
|
|
|
|
|
// Timestamp column data for index optimizations
|
|
|
|
|
$jobParams['minTimestamp'] = '0';
|
|
|
|
|
$jobParams['maxTimestamp'] = '0';
|
|
|
|
|
$jobParams['count'] = 0;
|
|
|
|
|
// Unique column for replica lag avoidance
|
|
|
|
|
if ( isset( $params['uniqueKey'] ) ) {
|
|
|
|
|
$jobParams['uniqueKey'] = $params['uniqueKey'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Insert jobs into queue!
|
|
|
|
|
foreach ( $res as $row ) {
|
2023-10-07 19:14:31 +00:00
|
|
|
// Since the ORDER BY is ASC, set the min timestamp with first row
|
2023-02-28 05:51:43 +00:00
|
|
|
if ( $jobParams['count'] === 0 ) {
|
|
|
|
|
$jobParams['minTimestamp'] = $row->$timestampC;
|
|
|
|
|
}
|
2023-10-07 19:14:31 +00:00
|
|
|
// Keep updating the last timestamp, so it should be correct
|
|
|
|
|
// when the last item is added.
|
2023-02-28 05:51:43 +00:00
|
|
|
$jobParams['maxTimestamp'] = $row->$timestampC;
|
2023-10-07 19:14:31 +00:00
|
|
|
// Update row counter
|
2023-02-28 05:51:43 +00:00
|
|
|
$jobParams['count']++;
|
2023-10-07 19:14:31 +00:00
|
|
|
// Once a job has $wgUpdateRowsPerJob rows, add it to the queue
|
2023-03-01 03:20:34 +00:00
|
|
|
if ( $jobParams['count'] >= $this->updateRowsPerJob ) {
|
2023-03-09 23:52:40 +00:00
|
|
|
$jobs[] = new JobSpecification( 'renameUser', $jobParams, [], $oldTitle );
|
2023-02-28 05:51:43 +00:00
|
|
|
$jobParams['minTimestamp'] = '0';
|
|
|
|
|
$jobParams['maxTimestamp'] = '0';
|
|
|
|
|
$jobParams['count'] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-07 19:14:31 +00:00
|
|
|
// If there are any job rows left, add it to the queue as one job
|
2023-02-28 05:51:43 +00:00
|
|
|
if ( $jobParams['count'] > 0 ) {
|
2023-03-09 23:52:40 +00:00
|
|
|
$jobs[] = new JobSpecification( 'renameUser', $jobParams, [], $oldTitle );
|
2023-02-28 05:51:43 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Log it!
|
|
|
|
|
$logEntry = new ManualLogEntry( 'renameuser', 'renameuser' );
|
|
|
|
|
$logEntry->setPerformer( $this->renamer );
|
|
|
|
|
$logEntry->setTarget( $oldTitle );
|
|
|
|
|
$logEntry->setComment( $this->reason );
|
|
|
|
|
$logEntry->setParameters( [
|
|
|
|
|
'4::olduser' => $this->old,
|
|
|
|
|
'5::newuser' => $this->new,
|
|
|
|
|
'6::edits' => $contribs
|
|
|
|
|
] );
|
|
|
|
|
$logid = $logEntry->insert();
|
|
|
|
|
|
|
|
|
|
// Insert any jobs as needed. If this fails, then an exception will be thrown and the
|
|
|
|
|
// DB transaction will be rolled back. If it succeeds but the DB commit fails, then the
|
|
|
|
|
// jobs will see that the transaction was not committed and will cancel themselves.
|
|
|
|
|
$count = count( $jobs );
|
|
|
|
|
if ( $count > 0 ) {
|
2023-03-01 03:20:34 +00:00
|
|
|
$this->jobQueueGroup->push( $jobs );
|
2023-10-07 19:14:31 +00:00
|
|
|
$this->debug( "Queued $count jobs for rename from {$this->old} to {$this->new}" );
|
2023-02-28 05:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Commit the transaction
|
|
|
|
|
$dbw->endAtomic( __METHOD__ );
|
|
|
|
|
|
|
|
|
|
$fname = __METHOD__;
|
|
|
|
|
$dbw->onTransactionCommitOrIdle(
|
|
|
|
|
function () use ( $dbw, $logEntry, $logid, $fname ) {
|
|
|
|
|
$dbw->startAtomic( $fname );
|
|
|
|
|
// Clear caches and inform authentication plugins
|
2023-03-01 03:20:34 +00:00
|
|
|
$user = $this->userFactory->newFromId( $this->uid );
|
2024-01-23 14:01:06 +00:00
|
|
|
$user->load( IDBAccessObject::READ_LATEST );
|
2023-02-28 05:51:43 +00:00
|
|
|
// Trigger the UserSaveSettings hook
|
|
|
|
|
$user->saveSettings();
|
|
|
|
|
$this->hookRunner->onRenameUserComplete( $this->uid, $this->old, $this->new );
|
|
|
|
|
// Publish to RC
|
|
|
|
|
$logEntry->publish( $logid );
|
|
|
|
|
$dbw->endAtomic( $fname );
|
|
|
|
|
},
|
|
|
|
|
$fname
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-07 19:14:31 +00:00
|
|
|
$this->debug( "Finished rename from {$this->old} to {$this->new}" );
|
2023-02-28 05:51:43 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-10-07 19:14:31 +00:00
|
|
|
* @param string $name Current wiki local username
|
2023-02-28 05:51:43 +00:00
|
|
|
* @return int Returns 0 if no row was found
|
|
|
|
|
*/
|
2023-03-01 03:20:34 +00:00
|
|
|
private function lockUserAndGetId( $name ) {
|
2023-10-31 12:58:13 +00:00
|
|
|
return (int)$this->dbProvider->getPrimaryDatabase()->newSelectQueryBuilder()
|
2023-09-19 11:06:53 +00:00
|
|
|
->select( 'user_id' )
|
|
|
|
|
->forUpdate()
|
|
|
|
|
->from( 'user' )
|
|
|
|
|
->where( [ 'user_name' => $name ] )
|
|
|
|
|
->caller( __METHOD__ )->fetchField();
|
2023-02-28 05:51:43 +00:00
|
|
|
}
|
|
|
|
|
}
|