Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172559

Change subject: Reduce global function count.
......................................................................

Reduce global function count.

Swap one for closure, one for function moved to MW core in
I8ae145035de9d349710971f17551da637e4d2242

Change-Id: I7b26698d026ecb4f9615b68e14aeeccfe0264aef
---
M wmf-config/throttle.php
1 file changed, 3 insertions(+), 25 deletions(-)


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

diff --git a/wmf-config/throttle.php b/wmf-config/throttle.php
index 4574997..b36fe4a 100644
--- a/wmf-config/throttle.php
+++ b/wmf-config/throttle.php
@@ -38,32 +38,10 @@
 
 ## Add throttling definitions above.
 
-## Helper methods:
-
-/**
- * Determines if an IP address is a list of CIDR a.b.c.d/n ranges.
- *
- * @param string $ip the IP to check
- * @param array $range the IP ranges, each element a range
- *
- * @return Boolean true if the specified adress belongs to the specified 
range; otherwise, false.
- */
-function inIPRanges ( $ip, $ranges ) {
-       foreach ( $ranges as $range ) {
-               if ( IP::isInRange( $ip, $range ) ) {
-                       return true;
-               }
-       }
-       return false;
-}
-
-# Will eventually raise value when MediaWiki is fully initialized:
-$wgExtensionFunctions[] = 'efRaiseAccountCreationThrottle';
-
 /**
  * Helper to easily add a throttling request.
  */
-function efRaiseAccountCreationThrottle() {
+$wgExtensionFunctions[] = function() {
        global $wmgThrottlingExceptions, $wgDBname, $wgRequest;
 
        foreach ( $wmgThrottlingExceptions as $options ) {
@@ -100,7 +78,7 @@
                }
                if ( isset ( $options['range'] ) ) {
                        //Checks if the IP is in range
-                       if ( is_array( $options['range'] ) && !inIPRanges( $ip, 
$options['range'] ) ) {
+                       if ( is_array( $options['range'] ) && !IP::isInRanges( 
$ip, $options['range'] ) ) {
                                continue;
                        } elseif ( !IP::isInRange( $ip, $options['range'] ) ) {
                                continue;
@@ -116,5 +94,5 @@
                }
                return; # No point in proceeding to another entry
        }
-}
+};
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b26698d026ecb4f9615b68e14aeeccfe0264aef
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>

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

Reply via email to