Dmaza has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376091 )

Change subject: Fix confusing warning message on throtthled filters
......................................................................

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: T54321
Change-Id: I5c6e434249d5c9649eb2d7c5b16b9ecb1f530c8a
---
M i18n/en.json
M includes/Views/AbuseFilterViewEdit.php
2 files changed, 13 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter 
refs/changes/91/376091/1

diff --git a/i18n/en.json b/i18n/en.json
index 649fc3e..7db1687 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -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:''' 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:",
diff --git a/includes/Views/AbuseFilterViewEdit.php 
b/includes/Views/AbuseFilterViewEdit.php
index d4f6cc1..d33fc3e 100644
--- a/includes/Views/AbuseFilterViewEdit.php
+++ b/includes/Views/AbuseFilterViewEdit.php
@@ -527,18 +527,21 @@
                }
 
                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 ( !empty( $throttledActions ) ) {
+                               $throttledActions = join( '|', array_keys( 
$throttledActions ) );
+                               $flags .= $out->parse(
+                                       $this->msg( 
'abusefilter-edit-throttled' )->rawParams( $throttledActions )->text()
+                               );
+                       }
                }
 
                foreach ( $checkboxes as $checkboxId ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c6e434249d5c9649eb2d7c5b16b9ecb1f530c8a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Dmaza <dm...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to