Further clarify docs for emergency disable

This is a follow-up to Ic3bc6e36506973b19a9b1bcecbc1a5080faed2ec. I
believe it's important to specify how many recent actions we're looking
at, and I also think it's not nice to rely on a variable amount of
actions to determine whether a filter should be throttled. Also, require
a $group parameter in filterUsedKey (we always pass one, and there's no
reason not to).

Change-Id: I0384d3f1913ead593f605248950606c81c8f8542
This commit is contained in:
Daimona Eaytoy 2018-11-26 20:22:47 +01:00
parent 6be748aae5
commit 6aff37fb52
2 changed files with 5 additions and 3 deletions

View file

@ -264,7 +264,7 @@
"default": 0.05
},
"_merge_strategy": "array_plus",
"description": "Disable a filter if it matches more than X actions, constituting more than Y% (e.g. 0.05 = 5%) of the last actions, and the filter has been modified in the last S seconds. X is AbuseFilterEmergencyDisableCount, Y is AbuseFilterEmergencyDisableThreshold and S is AbuseFilterEmergencyDisableAge."
"description": "Disable potentially dangerous action of a filter if it matches more than X actions, constituting more than Y% (e.g. 0.05 = 5%) of the last Z actions, and the filter has been modified in the last S seconds. X is AbuseFilterEmergencyDisableCount, Y is AbuseFilterEmergencyDisableThreshold, S is AbuseFilterEmergencyDisableAge and Z is a number between 1 and AbuseFilterProfileActionsCap."
},
"AbuseFilterEmergencyDisableCount": {
"value": {

View file

@ -2020,6 +2020,8 @@ class AbuseFilter {
$wgAbuseFilterEmergencyDisableAge;
$stash = ObjectCache::getMainStashInstance();
// @ToDo this is an amount between 1 and AbuseFilterProfileActionsCap, which means that the
// reliability of this number may strongly vary. We should instead use a fixed one.
$totalActions = $stash->get( self::filterUsedKey( $group ) );
foreach ( $filters as $filter ) {
@ -2081,10 +2083,10 @@ class AbuseFilter {
}
/**
* @param string|null $group The filter's group (as defined in $wgAbuseFilterValidGroups)
* @param string $group The filter's group (as defined in $wgAbuseFilterValidGroups)
* @return string
*/
public static function filterUsedKey( $group = null ) {
public static function filterUsedKey( $group ) {
return wfMemcKey( 'abusefilter', 'stats', 'total', $group );
}