From 274bddfb575ebfd1f0d4e7ac59dcc7a34b02ae52 Mon Sep 17 00:00:00 2001 From: Eddie Greiner-Petter Date: Mon, 13 Mar 2017 18:33:35 +0100 Subject: [PATCH] Show better error for anons on Special:EmailUser When a anon user visits Special:EmailUser, the PermissionError message is shown (as only members of the group "user" (all logged in users) are allowed to do this). There is a better error message, which tells "You must be logged in and have a valid email adress in your preferences." available, but was only shown to users who are logged in but did not have a valid mail adress in their settings, because the check for the permission "emailuser" happened before the check for the valid mail (which returns false for anon users). Exchanging the order of those makes the right error message appear. Bug: T160309 Change-Id: I26175df1f7577937d9781950058ca458984ce2cb --- includes/specials/SpecialEmailuser.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 085b68d6d8..a69406cb8d 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -231,14 +231,15 @@ class SpecialEmailUser extends UnlistedSpecialPage { return 'usermaildisabled'; } - if ( !$user->isAllowed( 'sendemail' ) ) { - return 'badaccess'; - } - + // Run this before $user->isAllowed, to show appropriate message to anons (T160309) if ( !$user->isEmailConfirmed() ) { return 'mailnologin'; } + if ( !$user->isAllowed( 'sendemail' ) ) { + return 'badaccess'; + } + if ( $user->isBlockedFromEmailuser() ) { wfDebug( "User is blocked from sending e-mail.\n" ); -- 2.20.1