r38955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38954‎ | r38955 | r38956 >
Date:21:43, 8 August 2008
Author:aaron
Status:old
Tags:
Comment:
$wgPasswordAttemptThrottle cleanup
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -3362,4 +3362,4 @@
33633363 * Limit password attempts to X attempts per Y seconds per IP per account.
33643364 * Requires memcached.
33653365 */
3366 -$wgPasswordAttemptThrottle = array( 5, 300 );
\ No newline at end of file
 3366+$wgPasswordAttemptThrottle = array( 'count' => 5, 'seconds' => 300 );
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -375,19 +375,19 @@
376376 }
377377
378378 global $wgPasswordAttemptThrottle;
379 - if (is_array($wgPasswordAttemptThrottle) && count($wgPasswordAttemptThrottle) >=2) {
380 - list($count,$period) = $wgPasswordAttemptThrottle;
 379+ if ( is_array($wgPasswordAttemptThrottle) ) {
381380 $key = wfMemcKey( 'password-throttle', wfGetIP(), $this->mName );
 381+ $count = $wgPasswordAttemptThrottle['count'];
 382+ $period = $wgPasswordAttemptThrottle['seconds'];
382383
383384 global $wgMemc;
384385 $cur = $wgMemc->get($key);
385 - if ($cur>0 && $cur<$count) {
 386+ if ( !$cur ) {
 387+ $wgMemc->add( $key, 1, $period ); // start counter
 388+ } else if ( $cur < $count ) {
386389 $wgMemc->incr($key);
387 - // Okay
388 - } elseif ($cur>0) {
 390+ } else if ( $cur >= $count ) {
389391 return self::THROTTLED;
390 - } elseif (!$cur) {
391 - $wgMemc->add( $key, 1, $period );
392392 }
393393 }
394394

Status & tagging log