X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmail%2FEmailNotification.php;h=cba68ef587917d61dd1570be84b914094d63104f;hb=4accd44583a6e4af38648a4af11f4cb5a21542f1;hp=acf2c2e44644f1e538b5da7e411e7b201ae50ca4;hpb=a44ae41d5806992c7b5524b8098022856f03f016;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index acf2c2e446..cba68ef587 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -173,13 +173,23 @@ class EmailNotification { * @param string $pageStatus * @throws MWException */ - public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, - $oldid, $watchers, $pageStatus = 'changed' ) { + public function actuallyNotifyOnPageChange( + $editor, + $title, + $timestamp, + $summary, + $minorEdit, + $oldid, + $watchers, + $pageStatus = 'changed' + ) { # we use $wgPasswordSender as sender's address global $wgUsersNotifiedOnAllChanges; global $wgEnotifWatchlist, $wgBlockDisablesLogin; global $wgEnotifMinorEdits, $wgEnotifUserTalk; + $messageCache = MediaWikiServices::getInstance()->getMessageCache(); + # The following code is only run, if several conditions are met: # 1. EmailNotification for pages (other than user_talk pages) must be enabled # 2. minor edits (changes) are only regarded if the global flag indicates so @@ -210,7 +220,7 @@ class EmailNotification { && $this->canSendUserTalkEmail( $editor, $title, $minorEdit ) ) { $targetUser = User::newFromName( $title->getText() ); - $this->compose( $targetUser, self::USER_TALK ); + $this->compose( $targetUser, self::USER_TALK, $messageCache ); $userTalkId = $targetUser->getId(); } @@ -224,10 +234,12 @@ class EmailNotification { && $watchingUser->isEmailConfirmed() && $watchingUser->getId() != $userTalkId && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges ) - && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() ) + // @TODO Partial blocks should not prevent the user from logging in. + // see: https://phabricator.wikimedia.org/T208895 + && !( $wgBlockDisablesLogin && $watchingUser->getBlock() ) && Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) { - $this->compose( $watchingUser, self::WATCHLIST ); + $this->compose( $watchingUser, self::WATCHLIST, $messageCache ); } } } @@ -239,7 +251,7 @@ class EmailNotification { continue; } $user = User::newFromName( $name ); - $this->compose( $user, self::ALL_CHANGES ); + $this->compose( $user, self::ALL_CHANGES, $messageCache ); } $this->sendMails(); @@ -262,7 +274,9 @@ class EmailNotification { wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" ); } elseif ( $targetUser->getId() == $editor->getId() ) { wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" ); - } elseif ( $wgBlockDisablesLogin && $targetUser->isBlocked() ) { + } elseif ( $wgBlockDisablesLogin && $targetUser->getBlock() ) { + // @TODO Partial blocks should not prevent the user from logging in. + // see: https://phabricator.wikimedia.org/T208895 wfDebug( __METHOD__ . ": talk page owner is blocked and cannot login, no notification sent\n" ); } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) && ( !$minorEdit || $targetUser->getOption( 'enotifminoredits' ) ) @@ -284,8 +298,9 @@ class EmailNotification { /** * Generate the generic "this page has been changed" e-mail text. + * @param MessageCache $messageCache */ - private function composeCommonMailtext() { + private function composeCommonMailtext( MessageCache $messageCache ) { global $wgPasswordSender, $wgNoReplyAddress; global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress; global $wgEnotifImpersonal, $wgEnotifUseRealName; @@ -370,7 +385,7 @@ class EmailNotification { $body = wfMessage( 'enotif_body' )->inContentLanguage()->plain(); $body = strtr( $body, $keys ); - $body = MessageCache::singleton()->transform( $body, false, null, $this->title ); + $body = $messageCache->transform( $body, false, null, $this->title ); $this->body = wordwrap( strtr( $body, $postTransformKeys ), 72 ); # Reveal the page editor's address as REPLY-TO address only if @@ -402,12 +417,13 @@ class EmailNotification { * Call sendMails() to send any mails that were queued. * @param User $user * @param string $source + * @param MessageCache $messageCache */ - function compose( $user, $source ) { + private function compose( $user, $source, MessageCache $messageCache ) { global $wgEnotifImpersonal; if ( !$this->composed_common ) { - $this->composeCommonMailtext(); + $this->composeCommonMailtext( $messageCache ); } if ( $wgEnotifImpersonal ) { @@ -420,7 +436,7 @@ class EmailNotification { /** * Send any queued mails */ - function sendMails() { + private function sendMails() { global $wgEnotifImpersonal; if ( $wgEnotifImpersonal ) { $this->sendImpersonal( $this->mailTargets ); @@ -436,9 +452,8 @@ class EmailNotification { * @param User $watchingUser * @param string $source * @return Status - * @private */ - function sendPersonalised( $watchingUser, $source ) { + private function sendPersonalised( $watchingUser, $source ) { global $wgEnotifUseRealName; // From the PHP manual: // Note: The to parameter cannot be an address in the form of @@ -477,7 +492,7 @@ class EmailNotification { * @param MailAddress[] $addresses * @return Status|null */ - function sendImpersonal( $addresses ) { + private function sendImpersonal( $addresses ) { if ( empty( $addresses ) ) { return null; }