Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/181401
Change subject: Always try to set an email in
CentralAuthUser::attemptAutoMigration
......................................................................
Always try to set an email in CentralAuthUser::attemptAutoMigration
Sometimes the home wiki might not have an email address set, but
a password confirmed account has, so use that, to prevent creating
global accounts without emails set.
Change-Id: I0d8e95b9fff6a2da68992e792759cb6c117c4d27
---
M includes/CentralAuthUser.php
1 file changed, 44 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/01/181401/1
diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index ab617cd..5aca903 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -794,7 +794,7 @@
// Matches the pre-authenticated password, yay!
$method = 'password';
} elseif ( $local['emailAuthenticated'] && isset(
$passingMail[$local['email']] ) ) {
- // Same email addresss as primary means we know
they could
+ // Same email addresss as primary or password
confirmed means we know they could
// reset their password, so we give them the
account.
// Authenticated email addresses only to
prevent merges with malicious users
$method = 'mail';
@@ -908,6 +908,39 @@
}
/**
+ * Choose an email address to use from an array as obtained via
self::queryUnattached
+ *
+ * @param array[] $wikisToAttach
+ */
+ private function chooseEmail( $wikisToAttach ) {
+ if ( $this->mEmail ) {
+ return;
+ }
+
+ // Try authenticated emails first
+ foreach ( $wikisToAttach as $attachWiki ) {
+ if ( $attachWiki['email'] &&
$attachWiki['emailAuthenticated'] ) {
+ $this->mEmail = $attachWiki['email'];
+ $this->mEmailAuthenticated =
$attachWiki['emailAuthenticated'];
+ break;
+ }
+ }
+
+ if ( $this->mEmail ) {
+ return;
+ }
+
+ // Let's try unconfirmed addresses, better than nothing
+ foreach ( $wikisToAttach as $attachWiki ) {
+ if ( $attachWiki['email'] ) {
+ $this->mEmail = $attachWiki['email'];
+ $this->mEmailAuthenticated =
$attachWiki['emailAuthenticated'];
+ break;
+ }
+ }
+ }
+
+ /**
* Pick a winning master account and try to auto-merge as many as
possible.
* @fixme add some locking or something
*
@@ -955,14 +988,20 @@
return false;
}
+ $wikisToAttach = array_intersect_key( $migrationSet, $attach );
+
+ // The home wiki might not have an email set, but maybe an
other account has one?
+ $this->chooseEmail( $wikisToAttach );
+
// storeGlobalData clears $this->mHomeWiki
$homeWiki = $this->mHomeWiki;
// Actually do the migration
$ok = $this->storeGlobalData(
- $home['id'],
- $home['password'],
- $home['email'],
- $home['emailAuthenticated'] );
+ $home['id'],
+ $home['password'],
+ $this->mEmail,
+ $this->mEmailAuthenticated
+ );
if ( !$ok ) {
wfDebugLog( 'CentralAuth',
--
To view, visit https://gerrit.wikimedia.org/r/181401
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d8e95b9fff6a2da68992e792759cb6c117c4d27
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits