From a60c42b0893d3403e2bef0f7d8a5dc935c7d95ca Mon Sep 17 00:00:00 2001
From: Chad Horohoe <chadh@wikimedia.org>
Date: Tue, 26 Apr 2016 11:24:56 -0700
Subject: [PATCH] Use global cache keys login/create account rate limitting

If you are running multiple wikis, you probably want the rate limit
on one wiki to apply to all wikis

Bug: T126685
Change-Id: Id662742c7af1b26811f5b0aa199176cb9a7658d9
---
 includes/specials/SpecialUserlogin.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php
index 9a2e194..47dd117 100644
--- a/includes/specials/SpecialUserlogin.php
+++ b/includes/specials/SpecialUserlogin.php
@@ -511,7 +511,7 @@ class LoginForm extends SpecialPage {
 				"allowed account creation w/o throttle\n" );
 		} else {
 			if ( ( $wgAccountCreationThrottle && $currentUser->isPingLimitable() ) ) {
-				$key = wfMemcKey( 'acctcreate', 'ip', $ip );
+				$key = 'global:acctcreate:ip:' . $ip;
 				$value = $wgMemc->get( $key );
 				if ( !$value ) {
 					$wgMemc->set( $key, 0, 86400 );
@@ -728,7 +728,7 @@ class LoginForm extends SpecialPage {
 
 		$throttleCount = 0;
 		if ( is_array( $wgPasswordAttemptThrottle ) ) {
-			$throttleKey = wfMemcKey( 'password-throttle', $wgRequest->getIP(), md5( $username ) );
+			$throttleKey = 'global:password-throttle:' . $wgRequest->getIP() . ':' . md5( $username );
 			$count = $wgPasswordAttemptThrottle['count'];
 			$period = $wgPasswordAttemptThrottle['seconds'];
 
@@ -754,7 +754,7 @@ class LoginForm extends SpecialPage {
 		global $wgMemc, $wgRequest;
 		$username = trim( $username ); // sanity
 
-		$throttleKey = wfMemcKey( 'password-throttle', $wgRequest->getIP(), md5( $username ) );
+		$throttleKey = 'global:password-throttle:' . $wgRequest->getIP() . ':' . md5( $username );
 		$wgMemc->delete( $throttleKey );
 	}
 
-- 
2.8.1

