* (bug 20595) Don't increment ping value right after setting it the first time (jumpi...
authorAaron Schulz <aaron@users.mediawiki.org>
Mon, 12 Oct 2009 23:54:48 +0000 (23:54 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Mon, 12 Oct 2009 23:54:48 +0000 (23:54 +0000)
* Use memc->set() rather than using add(). The later just does an existence check on the current key, which is useless here.

includes/User.php

index ffc0963..29b8184 100644 (file)
@@ -1283,6 +1283,7 @@ class User {
                        list( $max, $period ) = $limit;
                        $summary = "(limit $max in {$period}s)";
                        $count = $wgMemc->get( $key );
+                       // Already pinged?
                        if( $count ) {
                                if( $count > $max ) {
                                        wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
@@ -1293,11 +1294,11 @@ class User {
                                } else {
                                        wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );
                                }
+                               $wgMemc->incr( $key );
                        } else {
                                wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
-                               $wgMemc->add( $key, 1, intval( $period ) );
+                               $wgMemc->set( $key, 1, intval( $period ) ); // first ping
                        }
-                       $wgMemc->incr( $key );
                }
 
                wfProfileOut( __METHOD__ );