+
+ global $wgPasswordAttemptThrottle;
+
+ $throttleCount=0;
+ if ( is_array($wgPasswordAttemptThrottle) ) {
+ $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) );
+ $count = $wgPasswordAttemptThrottle['count'];
+ $period = $wgPasswordAttemptThrottle['seconds'];
+
+ global $wgMemc;
+ $throttleCount = $wgMemc->get($throttleKey);
+ if ( !$throttleCount ) {
+ $wgMemc->add( $throttleKey, 1, $period ); // start counter
+ } else if ( $throttleCount < $count ) {
+ $wgMemc->incr($throttleKey);
+ } else if ( $throttleCount >= $count ) {
+ return self::THROTTLED;
+ }
+ }
+
+ // Load $wgUser now, and check to see if we're logging in as the same
+ // name. This is necessary because loading $wgUser (say by calling
+ // getName()) calls the UserLoadFromSession hook, which potentially
+ // creates the user in the database. Until we load $wgUser, checking
+ // for user existence using User::newFromName($name)->getId() below
+ // will effectively be using stale data.
+ if ( $wgUser->getName() === $this->mName ) {
+ wfDebug( __METHOD__.": already logged in as {$this->mName}\n" );
+ return self::SUCCESS;
+ }