From: Eddie Greiner-Petter Date: Mon, 13 Mar 2017 17:33:35 +0000 (+0100) Subject: Show better error for anons on Special:EmailUser X-Git-Tag: 1.31.0-rc.0~3784^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=274bddfb575ebfd1f0d4e7ac59dcc7a34b02ae52;p=lhc%2Fweb%2Fwiklou.git 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 --- 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" );