diff --git a/CentralAuth.i18n.php b/CentralAuth.i18n.php
index 1d63842..5b38d75 100644
--- a/CentralAuth.i18n.php
+++ b/CentralAuth.i18n.php
@@ -220,6 +220,7 @@ The passwords for local accounts created before the merge will revert to their p
'action-centralauth-globalrename' => 'globally rename a user',
'centralauth-globalrename-nonexistent' => 'Global account "<nowiki>1ドル</nowiki>" does not exist.',
'centralauth-globalrename-in-progress' => 'There is already a global rename in progress for <nowiki>1ドル</nowiki>.',
+ 'centralauth-globalrename-tempdisallowed' => 'Global account "<nowiki>1ドル</nowiki>" has more than 2ドル edits. Globally renaming such accounts has been temporarily disallowed while the code is experime
// List of global users
'globalusers' => 'Global user list',
@@ -747,6 +748,7 @@ See also:
* 4ドル - the new username',
'right-centralauth-globalrename' => '{{doc-right|centralauth-globalrename}}',
'centralauth-globalrename-in-progress' => 'Error message shown when a global rename is already in progress on this username.',
+ 'centralauth-globalrename-tempdisallowed' => 'Error message shown when trying to rename a user with too many edits (default: 5000). This limitation will hopefully go away when we\'re happy with the
);
/** Afrikaans (Afrikaans)
diff --git a/CentralAuthHooks.php b/CentralAuthHooks.php
index ee9191f..7725528 100644
--- a/CentralAuthHooks.php
+++ b/CentralAuthHooks.php
@@ -864,7 +864,11 @@ class CentralAuthHooks {
* @param &$retval int a LoginForm class constant to return from authenticateUserData (default is LoginForm::ABORTED)
*/
static function onAbortLogin( $user, $password, &$retval ) {
- if ( !CentralAuthUser::getCentralDB()->lockIsFree( "centralauth-globalrename:" . $user->getName(), __METHOD__ ) ) {
+ global $wgMemc;
+ if (
+ !CentralAuthUser::getCentralDB()->lockIsFree( "centralauth-globalrename:" . $user->getName(), __METHOD__ ) ||
+ $wgMemc->get( CentralAuthUser::memcKey( 'globalrename', sha1( $user->getName() ) ) )
+ ) {
$retval = LoginForm::ABORTED;
return false;
}
diff --git a/LocalRenameUserJob.php b/LocalRenameUserJob.php
index d1d117d..e67c068 100644
--- a/LocalRenameUserJob.php
+++ b/LocalRenameUserJob.php
@@ -21,19 +21,13 @@ class CentralAuthLocalRenameUserJob extends Job {
);
if ( $rus->rename() ) {
- // TODO: For renames of more than RENAMEUSER_CONTRIBJOB (default: 5000), this might need to take place in CentralAuthHooks::onRenameUserComplete
- $wikiListKey = CentralAuthUser::memcKey( 'globalrename', sha1( $from ) );
+ // TODO: For renames of more than RENAMEUSER_CONTRIBJOB (default: 5000), we might want to do this in CentralAuthHooks::onRenameUserComplete instead
+ $wikiListKey = CentralAuthUser::memcKey( 'globalrename', sha1( $to ) );
$wikiList = $wgMemc->get( $wikiListKey ); // TODO: Find a way to completely disable global renaming if memcache isn't available on all wikis. We can't just quit here if we see that
$wikiList = array_diff( $wikiList, array( $wgDBname ) ); // Remove this wiki from the list.
if ( count( $wikiList ) == 0 ) {
$wgMemc->delete( $wikiListKey );
- // Unlock the user
- if ( !$this->params['startedLocked'] ) { // If the user was locked before we started renaming, we need to make sure we don't unlock them silently at the end.
- $globalUser = new CentralAuthUser( $to );
- $globalUser->adminUnlock();
- }
-
// Make log entry on the wiki which this rename job was started on.
$db = wfGetDB( DB_MASTER, array(), $this->params['startedFrom'] );
$title = Title::newFromText( "User:{$from}@global" );
diff --git a/specials/SpecialCentralAuth.php b/specials/SpecialCentralAuth.php
index c1edb7a..e7b6be4 100644
--- a/specials/SpecialCentralAuth.php
+++ b/specials/SpecialCentralAuth.php
@@ -25,7 +25,7 @@ class SpecialCentralAuth extends SpecialPage {
$this->mCanOversight = $this->getUser()->isAllowed( 'centralauth-oversight' );
$this->mCanEdit = $this->mCanUnmerge || $this->mCanLock || $this->mCanOversight;
AutoLoader::loadClass( 'SpecialRenameuser' );
- $this->mCanRename = $this->getUser()->isAllowed( 'centralauth-globalrename' ) && class_exists( 'SpecialRenameuser', false );
+ $this->mCanRename = $this->getUser()->isAllowed( 'centralauth-globalrename' ) && class_exists( 'RenameuserSQL', false ) && property_exists( 'RenameuserSQL', 'checkIfUserExists' );
$this->getOutput()->addModules( 'ext.centralauth' );
$this->getOutput()->addModuleStyles( 'ext.centralauth.noflash' );
$this->getOutput()->addJsConfigVars( 'wgMergeMethodDescriptions', $this->getMergeMethodDescriptions() );
@@ -217,6 +217,11 @@ class SpecialCentralAuth extends SpecialPage {
return true;
}
+ if ( $this->evaluateTotalEditcount() > RENAMEUSER_CONTRIBJOB ) {
+ $this->showError( 'centralauth-globalrename-tempdisallowed', $globalUser->getName(), RENAMEUSER_CONTRIBJOB );
+ return true;
+ }
+
$currentName = $globalUser->getName();
$newName = $this->getRequest()->getText( 'newname' );
@@ -241,12 +246,6 @@ class SpecialCentralAuth extends SpecialPage {
$cdb->lock( "centralauth-globalrename:" . $currentName, __METHOD__ );
$cdb->lock( "centralauth-globalrename:" . $newName, __METHOD__ );
- $startedLocked = $globalUser->isLocked();
- // Lock the user before we start changing anything.
- if ( !$startedLocked ) {
- $globalUser->adminLock();
- }
-
// Update the globaluser and localuser tables. The existing hooks should deal with globalnames/localnames...
$tables = array( 'globaluser' => 'gu', 'localuser' => 'lu' );
foreach ( $tables as $table => $prefix ) {
@@ -267,7 +266,6 @@ class SpecialCentralAuth extends SpecialPage {
'from' => $globalUser->getName(),
'to' => $newName,
'reason' => $this->getRequest()->getText( 'reason' ),
- 'startedLocked' => $startedLocked,
'startedFrom' => $wgDBname,
'startedByName' => $this->getUser()->getName(),
'startedById' => $this->getUser()->getID(),
@@ -276,7 +274,7 @@ class SpecialCentralAuth extends SpecialPage {
);
global $wgMemc;
- $wgMemc->set( CentralAuthUser::memcKey( 'globalrename', sha1( $currentName ) ), $globalUser->listAttached() );
+ $wgMemc->set( CentralAuthUser::memcKey( 'globalrename', sha1( $newName ) ), $globalUser->listAttached() );
// Put the job into the queue on each wiki it needs to run on
foreach ( $globalUser->listAttached() as $wiki ) {