BryanDavis has uploaded a new change for review.
https://gerrit.wikimedia.org/r/198441
Change subject: Ensure that emails are sent to correct email address
......................................................................
Ensure that emails are sent to correct email address
Ensure that the email address associated with non-global requests is the
address from the unattached account rather than any locally attached
account available on the wiki that processes the request.
Bug: T93444
Change-Id: I89e60cab405044d75957552ddd9f671259a0b66a
---
M includes/specials/SpecialGlobalRenameQueue.php
1 file changed, 48 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/41/198441/1
diff --git a/includes/specials/SpecialGlobalRenameQueue.php
b/includes/specials/SpecialGlobalRenameQueue.php
index af8d9aa..3b54e37 100644
--- a/includes/specials/SpecialGlobalRenameQueue.php
+++ b/includes/specials/SpecialGlobalRenameQueue.php
@@ -377,6 +377,13 @@
// our purposes, so just ensure that an accessor is called to
unstub
// the object.
$oldUser->getEmail();
+ if ( $request->userIsGlobal() ) {
+ $notifyEmail = MailAddress::newFromUser( $oldUser );
+ } else {
+ $notifyEmail = $this->getRemoteUserMailAddress(
+ $request->getWiki(), $request->getName()
+ );
+ }
$newUser = User::newFromName( $request->getNewName(),
'creatable' );
$status = new Status;
if ( $approved ) {
@@ -459,13 +466,53 @@
'CentralAuthRename',
"Sending $type email to
User:{$oldUser->getName()}/{$oldUser->getEmail()}"
);
- $oldUser->sendMail( $subject, $body );
+ $this->sendNotificationEmail( $notifyEmail,
$subject, $body );
} else {
$status->fatal(
'globalrenamequeue-request-savefailed' );
}
}
return $status;
}
+
+ /**
+ * Get a MailAddress for a user on a remote wiki
+ *
+ * @param string $wiki
+ * @param string $username
+ * @return MailAddress
+ */
+ protected function getRemoteUserMailAddress( $wiki, $username ) {
+ $lb = wfGetLB( $wiki );
+ $remoteDB = $lb->getConnection( DB_SLAVE, array(), $wiki );
+ $row = $remoteDB->selectRow(
+ 'user',
+ array( 'user_id' ),
+ array(
+ 'user_name' => User::getCanonicalName(
$username ),
+ ),
+ __METHOD__
+ );
+ $address = new MailAddress(
+ $row->user_email, $row->user_name, $row->user_real_name
+ );
+ $lb->reuseConnection( $remoteDB );
+ return $address;
+ }
+
+ /**
+ * Send an email notifying the user of the result of their request.
+ *
+ * @param MailAddress $to
+ * @param string $subject
+ * @param string $body
+ * @return Status
+ */
+ protected function sendNotificationEmail( MailAddress $to, $subject,
$body ) {
+ global $wgPasswordSender;
+ $from = new MailAddress( $wgPasswordfrom,
+ wfMessage( 'emailfrom' )->inContentLanguage()->text() );
+ return UserMailer::send( $to, $from, $subject, $body );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/198441
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I89e60cab405044d75957552ddd9f671259a0b66a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits