Fix confusing warning message on throtthled filters

A confusing warning message was displayed when filters
have af_throttled = true. That message was replaced with a
new one reflecting the behavior that is actually ocurring and
how to solve it

Bug: T54525
Change-Id: I5c6e434249d5c9649eb2d7c5b16b9ecb1f530c8a
This commit is contained in:
Dayllan Maza 2017-09-05 17:11:18 -03:00
parent 4c0839a32b
commit 539884f428
3 changed files with 21 additions and 11 deletions

View file

@ -135,7 +135,7 @@
"abusefilter-edit-status-label": "Statistics:",
"abusefilter-edit-status": "Of the last $1 {{PLURAL:$1|action|actions}}, this filter has matched $2 ($3%).",
"abusefilter-edit-status-profile": "Of the last $1 {{PLURAL:$1|action|actions}}, this filter has matched $2 ($3%).\nOn average, its run time is $4 ms, and it consumes $5 {{PLURAL:$5|condition|conditions}} of the condition limit.",
"abusefilter-edit-throttled": "'''Warning:''' This filter was automatically disabled as a safety measure.\nIt reached the limit of matching more than $1% of actions.",
"abusefilter-edit-throttled-warning": "'''Warning:''' This filter was automatically flagged as harmful. As a safety measure, the following actions will not execute ($1). Please review and [[mw:Extension:AbuseFilter/Conditions|optimize]] your conditions to remove this restriction",
"abusefilter-edit-new": "New filter",
"abusefilter-edit-save": "Save filter",
"abusefilter-edit-id": "Filter ID:",

View file

@ -166,7 +166,7 @@
"abusefilter-edit-status-label": "Field label for abuse filter statistics.\n{{Identical|Statistics}}",
"abusefilter-edit-status": "Parameters:\n* $1 - number of actions\n* $2 - matched count\n* $3 - matched percentage",
"abusefilter-edit-status-profile": "Parameters:\n* $1 - number of actions\n* $2 - matched count\n* $3 - matched percentage\n* $4 - time (in milliseconds)\n* $5 - number of conditions",
"abusefilter-edit-throttled": "Used as warning message. Parameters:\n* $1 - threshold percentage",
"abusefilter-edit-throttled-warning": "Used as warning message when the filter is throttled and actions will not execute. Parameters:\n* $1 - is a string containing the actions that will not execute",
"abusefilter-edit-new": "Field value in case an edited filter is new.",
"abusefilter-edit-save": "Submit button text to save a filter.",
"abusefilter-edit-id": "Field label for filter identifier.\n{{Identical|Filter ID}}",

View file

@ -527,18 +527,28 @@ class AbuseFilterViewEdit extends AbuseFilterView {
}
if ( isset( $row->af_throttled ) && $row->af_throttled ) {
global $wgAbuseFilterEmergencyDisableThreshold;
global $wgAbuseFilterRestrictions;
// determine emergency disable value for this action
$emergencyDisableThreshold = AbuseFilter::getEmergencyValue(
$wgAbuseFilterEmergencyDisableThreshold,
$row->af_group
$filterActions = explode( ',', $row->af_actions );
$throttledActions = array_intersect_key(
array_flip( $filterActions ),
array_filter( $wgAbuseFilterRestrictions )
);
$threshold_percent = sprintf( '%.2f', $emergencyDisableThreshold * 100 );
$flags .= $out->parse(
$this->msg( 'abusefilter-edit-throttled' )->numParams( $threshold_percent )->text()
);
if ( $throttledActions ) {
$throttledActions = array_map(
function ( $filterAction ) {
return $this->msg( 'abusefilter-action-' . $filterAction )->text();
},
array_keys( $throttledActions )
);
$flags .= $out->parse(
$this->msg( 'abusefilter-edit-throttled-warning' )
->plaintextParams( $lang->commaList( $throttledActions ) )
->text()
);
}
}
foreach ( $checkboxes as $checkboxId ) {