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
return "blockedemailuser";
}
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';
wfDebug( "Ping limiter triggered.\n" );
return 'actionthrottledtext';
$text .= $context->msg( 'emailuserfooter',
$from->name, $to->name )->inContentLanguage()->text();
$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 ) {
$error = false;
if ( !Hooks::run( 'EmailUser', [ &$to, &$from, &$subject, &$text, &$error ] ) ) {
if ( $error instanceof Status ) {