Fixed minor bug where the memcached value for how many accounts an IP had
authorNathaniel Herman <pinky@users.mediawiki.org>
Sun, 30 Nov 2008 17:33:11 +0000 (17:33 +0000)
committerNathaniel Herman <pinky@users.mediawiki.org>
Sun, 30 Nov 2008 17:33:11 +0000 (17:33 +0000)
created that day would be increased even if $wgAccountCreationThrottle was
hit. This meant if an IP hit the throttle and then the throttle was raised
later that day, the IP still couldn't create another account, because it
had marked them as having created another account, when their last account
creation had actually failed.

RELEASE-NOTES
includes/specials/SpecialUserlogin.php

index f16d1d9..d831515 100644 (file)
@@ -377,6 +377,12 @@ The following extensions are migrated into MediaWiki 1.14:
   now automatically removed from titles; these characters can accidentally end
   up in copy-and-pasted titles, and, by overriding normal bidirectional text
   handling, can lead to annoying behavior such as text rendering backwards
+* Fixed minor bug where the memcached value for how many accounts an IP had
+  created that day would be increased even if $wgAccountCreationThrottle was
+  hit. This meant if an IP hit the throttle and then the throttle was raised
+  later that day, the IP still couldn't create another account, because it
+  had marked them as having created another account, when their last account
+  creation had actually failed.
 
 === API changes in 1.14 ===
 
index 75b065d..6a4da7a 100644 (file)
@@ -311,14 +311,15 @@ class LoginForm {
 
                if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
                        $key = wfMemcKey( 'acctcreate', 'ip', $ip );
-                       $value = $wgMemc->incr( $key );
+                       $value = $wgMemc->get( $key );
                        if ( !$value ) {
-                               $wgMemc->set( $key, 1, 86400 );
+                               $wgMemc->set( $key, 0, 86400 );
                        }
-                       if ( $value > $wgAccountCreationThrottle ) {
+                       if ( $value >= $wgAccountCreationThrottle ) {
                                $this->throttleHit( $wgAccountCreationThrottle );
                                return false;
                        }
+                       $wgMemc->incr( $key );
                }
 
                if( !$wgAuth->addUser( $u, $this->mPassword, $this->mEmail, $this->mRealName ) ) {