From ade0321c66bf8a221cd5e98e39f304249c7e8d80 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 22 Aug 2018 15:09:30 -0700 Subject: [PATCH] Don't send email notifs to blocked users if $wgBlockDisablesLogin is true Bug: T199993 Change-Id: I47ed3599d61ca8177cdd0820dea4089fdb087d82 --- includes/Notifier.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/includes/Notifier.php b/includes/Notifier.php index fd5068cf..3d7ef59c 100644 --- a/includes/Notifier.php +++ b/includes/Notifier.php @@ -31,16 +31,22 @@ class EchoNotifier { * @return bool */ public static function notifyWithEmail( $user, $event ) { - global $wgEnableEmail; - - if ( !$wgEnableEmail ) { - return false; - } - // No valid email address or email notification - if ( !$user->isEmailConfirmed() || $user->getOption( 'echo-email-frequency' ) < 0 ) { + global $wgEnableEmail, $wgBlockDisablesLogin; + + if ( + // Email is globally disabled + !$wgEnableEmail || + // User does not have a valid and confirmed email address + !$user->isEmailConfirmed() || + // User has disabled Echo emails + $user->getOption( 'echo-email-frequency' ) < 0 || + // User is blocked and cannot log in (T199993) + ( $wgBlockDisablesLogin && $user->isBlocked() ) + ) { return false; } + // Final check on whether to send email for this user & event if ( !Hooks::run( 'EchoAbortEmailNotification', [ $user, $event ] ) ) { return false; -- 2.17.1