From: Kunal Mehta Date: Fri, 6 Oct 2017 07:36:07 +0000 (-0700) Subject: SpecialEmailUser: Don't increment pingLimiter() just for opening the page X-Git-Tag: 1.31.0-rc.0~1695^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=e31c9986a17f036ec89e2ef3f04519026e42ebf3;ds=sidebyside SpecialEmailUser: Don't increment pingLimiter() just for opening the page When checking whether the user can even send am email, don't increment the rate limits since they haven't sent an email yet. Only increment it once we're fairly sure that the email will actually get sent. Bug: T177575 Change-Id: I3f832accd6259c040438ebee4c94847faa108ea6 --- diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index 249be7f17f..30eb38d04a 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -280,7 +280,9 @@ class SpecialEmailUser extends UnlistedSpecialPage { return "blockedemailuser"; } - if ( $user->pingLimiter( 'emailuser' ) ) { + // Check the ping limiter without incrementing it - we'll check it + // again later and increment it on a successful send + if ( $user->pingLimiter( 'emailuser', 0 ) ) { wfDebug( "Ping limiter triggered.\n" ); return 'actionthrottledtext'; @@ -376,6 +378,11 @@ class SpecialEmailUser extends UnlistedSpecialPage { $text .= $context->msg( 'emailuserfooter', $from->name, $to->name )->inContentLanguage()->text(); + // Check and increment the rate limits + if ( $context->getUser()->pingLimiter( 'emailuser' ) ) { + throw new ThrottledError(); + } + $error = false; if ( !Hooks::run( 'EmailUser', [ &$to, &$from, &$subject, &$text, &$error ] ) ) { if ( $error instanceof Status ) {