Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / auth / ThrottlePreAuthenticationProvider.php
index e2123ef..3f6a47d 100644 (file)
@@ -65,13 +65,19 @@ class ThrottlePreAuthenticationProvider extends AbstractPreAuthenticationProvide
        public function setConfig( Config $config ) {
                parent::setConfig( $config );
 
+               $accountCreationThrottle = $this->config->get( 'AccountCreationThrottle' );
+               // Handle old $wgAccountCreationThrottle format (number of attempts per 24 hours)
+               if ( !is_array( $accountCreationThrottle ) ) {
+                       $accountCreationThrottle = [ [
+                               'count' => $accountCreationThrottle,
+                               'seconds' => 86400,
+                       ] ];
+               }
+
                // @codeCoverageIgnoreStart
                $this->throttleSettings += [
                // @codeCoverageIgnoreEnd
-                       'accountCreationThrottle' => [ [
-                               'count' => $this->config->get( 'AccountCreationThrottle' ),
-                               'seconds' => 86400,
-                       ] ],
+                       'accountCreationThrottle' => $accountCreationThrottle,
                        'passwordAttemptThrottle' => $this->config->get( 'PasswordAttemptThrottle' ),
                ];
 
@@ -107,7 +113,9 @@ class ThrottlePreAuthenticationProvider extends AbstractPreAuthenticationProvide
 
                $result = $this->accountCreationThrottle->increase( null, $ip, __METHOD__ );
                if ( $result ) {
-                       return \StatusValue::newFatal( 'acct_creation_throttle_hit', $result['count'] );
+                       $message = wfMessage( 'acct_creation_throttle_hit' )->params( $result['count'] )
+                               ->durationParams( $result['wait'] );
+                       return \StatusValue::newFatal( $message );
                }
 
                return \StatusValue::newGood();