Urbanecm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373695 )

Change subject: throttle.php: Separate the throttling definitions from the 
exception values itself
......................................................................

throttle.php: Separate the throttling definitions from the exception values 
itself

Bug: T167040
Change-Id: If97fef2b72401e50960fdecd44b95ce933635e4d
---
A wmf-config/throttle-analyze.php
M wmf-config/throttle.php
2 files changed, 47 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/95/373695/1

diff --git a/wmf-config/throttle-analyze.php b/wmf-config/throttle-analyze.php
new file mode 100644
index 0000000..27860e9
--- /dev/null
+++ b/wmf-config/throttle-analyze.php
@@ -0,0 +1,47 @@
+/**
+ * Helper to easily add a throttling request.
+ */
+$wgExtensionFunctions[] = function () {
+       global $wmgThrottlingExceptions, $wgDBname, $wgRequest;
+
+       foreach ( $wmgThrottlingExceptions as $options ) {
+               # Validate entry, skip when it does not apply to our case
+
+               # 1) skip when it does not apply to our database name
+
+               if ( isset( $options['dbname'] ) && !in_array( $wgDBname, 
(array)$options['dbname'] ) ) {
+                       continue;
+               }
+
+               # 2) skip expired entries
+               $inTimeWindow = time() >= strtotime( $options['from'] )
+                       && time() <= strtotime( $options['to'] );
+
+               if ( !$inTimeWindow ) {
+                       continue;
+               }
+
+               # 3) skip when throttle does not apply to the client IP
+               $ip = $wgRequest->getIP();
+               if ( isset ( $options['IP'] ) ) {
+                       $throttleIP = $options['IP'];
+               }
+               if ( isset( $throttleIP ) && !in_array( $ip, (array)$throttleIP 
) ) {
+                       continue;
+               }
+               if ( isset ( $options['range'] ) && !IP::isInRanges( $ip, 
(array)$options['range'] ) ) {
+                       continue;
+               }
+
+               # Finally) set up the throttle value
+               global $wgAccountCreationThrottle, $wgRateLimits;
+               if ( isset( $options['value'] ) && is_numeric( 
$options['value'] ) ) {
+                       $wgAccountCreationThrottle = $options['value'];
+               } else {
+                       $wgAccountCreationThrottle = 50; // Provide some sane 
default
+               }
+               $wgRateLimits['badcaptcha']['ip'] = [ 1000, 86400 ];
+               $wgRateLimits['badcaptcha']['newbie'] = [ 1000, 86400 ];
+               return; # No point in proceeding to another entry
+       }
+};
diff --git a/wmf-config/throttle.php b/wmf-config/throttle.php
index 1954828..3579776 100644
--- a/wmf-config/throttle.php
+++ b/wmf-config/throttle.php
@@ -38,50 +38,3 @@
 
 ## Add throttling definitions above.
 
-/**
- * Helper to easily add a throttling request.
- */
-$wgExtensionFunctions[] = function () {
-       global $wmgThrottlingExceptions, $wgDBname, $wgRequest;
-
-       foreach ( $wmgThrottlingExceptions as $options ) {
-               # Validate entry, skip when it does not apply to our case
-
-               # 1) skip when it does not apply to our database name
-
-               if ( isset( $options['dbname'] ) && !in_array( $wgDBname, 
(array)$options['dbname'] ) ) {
-                       continue;
-               }
-
-               # 2) skip expired entries
-               $inTimeWindow = time() >= strtotime( $options['from'] )
-                       && time() <= strtotime( $options['to'] );
-
-               if ( !$inTimeWindow ) {
-                       continue;
-               }
-
-               # 3) skip when throttle does not apply to the client IP
-               $ip = $wgRequest->getIP();
-               if ( isset ( $options['IP'] ) ) {
-                       $throttleIP = $options['IP'];
-               }
-               if ( isset( $throttleIP ) && !in_array( $ip, (array)$throttleIP 
) ) {
-                       continue;
-               }
-               if ( isset ( $options['range'] ) && !IP::isInRanges( $ip, 
(array)$options['range'] ) ) {
-                       continue;
-               }
-
-               # Finally) set up the throttle value
-               global $wgAccountCreationThrottle, $wgRateLimits;
-               if ( isset( $options['value'] ) && is_numeric( 
$options['value'] ) ) {
-                       $wgAccountCreationThrottle = $options['value'];
-               } else {
-                       $wgAccountCreationThrottle = 50; // Provide some sane 
default
-               }
-               $wgRateLimits['badcaptcha']['ip'] = [ 1000, 86400 ];
-               $wgRateLimits['badcaptcha']['newbie'] = [ 1000, 86400 ];
-               return; # No point in proceeding to another entry
-       }
-};

-- 
To view, visit https://gerrit.wikimedia.org/r/373695
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If97fef2b72401e50960fdecd44b95ce933635e4d
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Urbanecm <martin.urba...@wikimedia.cz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to