jenkins-bot has submitted this change and it was merged. ( 
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
---
M wmf-config/CommonSettings.php
A wmf-config/throttle-analyze.php
M wmf-config/throttle.php
3 files changed, 50 insertions(+), 47 deletions(-)

Approvals:
  Zfilipin: Looks good to me, approved
  Framawiki: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/wmf-config/CommonSettings.php b/wmf-config/CommonSettings.php
index ce9228c..f3d4195 100644
--- a/wmf-config/CommonSettings.php
+++ b/wmf-config/CommonSettings.php
@@ -1870,6 +1870,7 @@
 # Various system to allow/prevent flooding
 # (including exemptions for scheduled outreach events)
 require "$wmfConfigDir/throttle.php";
+require "$wmfConfigDir/throttle-analyze.php";
 
 if ( $wmgUseNewUserMessage ) {
        wfLoadExtension( 'NewUserMessage' );
diff --git a/wmf-config/throttle-analyze.php b/wmf-config/throttle-analyze.php
new file mode 100644
index 0000000..1757b8e
--- /dev/null
+++ b/wmf-config/throttle-analyze.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * 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: merged
Gerrit-Change-Id: If97fef2b72401e50960fdecd44b95ce933635e4d
Gerrit-PatchSet: 3
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Urbanecm <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Framawiki <[email protected]>
Gerrit-Reviewer: Zfilipin <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to