Merge "OutputPage::getCategories(): Add a possibility to distinguish "normal" and...
[lhc/web/wiklou.git] / includes / auth / Throttler.php
index 5b14a3b..6d3b2f4 100644 (file)
 namespace MediaWiki\Auth;
 
 use BagOStuff;
-use Config;
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerInterface;
 use Psr\Log\LogLevel;
-use Psr\Log\NullLogger;
-use User;
 
 /**
  * A helper class for throttling authentication attempts.
@@ -71,7 +69,7 @@ class Throttler implements LoggerAwareInterface {
                }
 
                if ( $conditions === null ) {
-                       $config = \ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+                       $config = MediaWikiServices::getInstance()->getMainConfig();
                        $conditions = $config->get( 'PasswordAttemptThrottle' );
                        $params += [
                                'type' => 'password',
@@ -138,7 +136,7 @@ class Throttler implements LoggerAwareInterface {
                                $this->cache->incr( $throttleKey );
                        } else { // throttled
                                $this->logRejection( [
-                                       'type' => $this->type,
+                                       'throttle' => $this->type,
                                        'index' => $index,
                                        'ip' => $ipKey,
                                        'username' => $username,
@@ -194,7 +192,7 @@ class Throttler implements LoggerAwareInterface {
        }
 
        protected function logRejection( array $context ) {
-               $logMsg = 'Throttle {type} hit, throttled for {expiry} seconds due to {count} attempts '
+               $logMsg = 'Throttle {throttle} hit, throttled for {expiry} seconds due to {count} attempts '
                        . 'from username {username} and IP {ip}';
 
                // If we are hitting a throttle for >= warningLimit attempts, it is much more likely to be