Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/204840
Change subject: forceRenameUsers: Replace _ in database name with -
......................................................................
forceRenameUsers: Replace _ in database name with -
Underscores (_) are not valid in usernames, and are normally replaced
with spaces. But those look funny to some people, so use dashes (-)
instead. Also canonicalize the username so we don't end up with invalid
usernames in the database.
Note: forceRenameUsers.php update in original commit was not cherry-picked
due to conflicts.
Change-Id: I56e83a23e25f90358b18e51d2d3d9679e0158c55
---
M includes/CentralAuthPlugin.php
M tests/CentralAuthPluginUsingDatabaseTest.php
2 files changed, 20 insertions(+), 18 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/40/204840/1
diff --git a/includes/CentralAuthPlugin.php b/includes/CentralAuthPlugin.php
index fb903a9..a9bcd74 100644
--- a/includes/CentralAuthPlugin.php
+++ b/includes/CentralAuthPlugin.php
@@ -51,23 +51,25 @@
if ( !$passwordMatch && $wgCentralAuthCheckSULMigration ) {
// Check to see if this is a user who was affected by a
global username
// collision during a forced migration to central auth
accounts.
- $renamedUsername = $username . '~' . wfWikiID();
- wfDebugLog( 'CentralAuth',
- "CentralAuthMigration: Checking for migration
of '{$username}' to '{$renamedUsername}'"
- );
+ $renamedUsername = User::getCanonicalName( $username .
'~' . str_replace( '_', '-', wfWikiID() ) );
+ if ( $renamedUsername !== false ) {
+ wfDebugLog( 'CentralAuth',
+ "CentralAuthMigration: Checking for
migration of '{$username}' to '{$renamedUsername}'"
+ );
- $renamed = new CentralAuthUser( $renamedUsername );
- $passwordMatch = self::checkPassword( $renamed,
$password );
+ $renamed = new CentralAuthUser(
$renamedUsername );
+ $passwordMatch = self::checkPassword( $renamed,
$password );
- // Remember that the user was authenticated under a
different name.
- if ( $passwordMatch ) {
- $this->sulMigrationName = $renamedUsername;
+ // Remember that the user was authenticated
under a different name.
+ if ( $passwordMatch ) {
+ $this->sulMigrationName =
$renamedUsername;
+ }
+
+ // Since we are falling back to check a force
migrated user, we are done
+ // regardless of password match status. We
don't want to try to
+ // automigrate or check detached accounts.
+ return $passwordMatch;
}
-
- // Since we are falling back to check a force migrated
user, we are done
- // regardless of password match status. We don't want
to try to
- // automigrate or check detached accounts.
- return $passwordMatch;
}
if ( !$central->exists() ) {
diff --git a/tests/CentralAuthPluginUsingDatabaseTest.php
b/tests/CentralAuthPluginUsingDatabaseTest.php
index 55ed6dc..24c9fdb 100644
--- a/tests/CentralAuthPluginUsingDatabaseTest.php
+++ b/tests/CentralAuthPluginUsingDatabaseTest.php
@@ -90,7 +90,7 @@
// Global user who was renamed when migrated
$u = new CentralAuthTestUser(
- 'GlobalUser~' . self::safeWfWikiID(),
+ 'GlobalUser~' . str_replace( '_', '-',
self::safeWfWikiID() ),
'GURP@ssword',
array( 'gu_id' => '1006' ),
array(
@@ -208,7 +208,7 @@
),
array(
'GlobalUser', 'GURP@ssword', true,
- true, 'GlobalUser~' . self::safeWfWikiID(),
+ true, 'GlobalUser~' . str_replace( '_', '-',
self::safeWfWikiID() ),
'wgCentralAuthCheckSULMigration enabled;
correct password',
),
array(
@@ -248,7 +248,7 @@
public function provideUpdateUserRenameAnnotation() {
return array(
array(
- 'GlobalUser', false, 'GlobalUser~' .
self::safeWfWikiID(),
+ 'GlobalUser', false, 'GlobalUser~' .
str_replace( '_', '-', self::safeWfWikiID() ),
false, false,
'wgCentralAuthCheckSULMigration disabled;
sulMigrationName set',
),
@@ -258,7 +258,7 @@
'wgCentralAuthCheckSULMigration disabled;
sulMigrationName unset',
),
array(
- 'GlobalUser', true, 'GlobalUser~' .
self::safeWfWikiID(),
+ 'GlobalUser', true, 'GlobalUser~' .
str_replace( '_', '-', self::safeWfWikiID() ),
true, true,
'wgCentralAuthCheckSULMigration enabled;
sulMigrationName set',
),
--
To view, visit https://gerrit.wikimedia.org/r/204840
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I56e83a23e25f90358b18e51d2d3d9679e0158c55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: wmf/1.26wmf1
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits