jenkins-bot has submitted this change and it was merged.
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(-)
Approvals:
Reedy: Looks good to me, approved
jenkins-bot: Verified
diff --git a/wmf-config/throttle.php b/wmf-config/throttle.php
index b29135a..24e0190 100644
--- a/wmf-config/throttle.php
+++ b/wmf-config/throttle.php
@@ -30,32 +30,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 ) {
@@ -92,7 +70,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;
@@ -108,5 +86,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: merged
Gerrit-Change-Id: I7b26698d026ecb4f9615b68e14aeeccfe0264aef
Gerrit-PatchSet: 2
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits