[MediaWiki-commits] [Gerrit] mediawiki...AbuseFilter[master]: Fix confusing warning message on throtthled filters

2017-09-14 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
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: T54525
Change-Id: I5c6e434249d5c9649eb2d7c5b16b9ecb1f530c8a
---
M i18n/en.json
M i18n/qqq.json
M includes/Views/AbuseFilterViewEdit.php
3 files changed, 21 insertions(+), 11 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 649fc3e..0d32b9f 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": "'''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/i18n/qqq.json b/i18n/qqq.json
index a7aff88..e2d5aec 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -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}}",
diff --git a/includes/Views/AbuseFilterViewEdit.php 
b/includes/Views/AbuseFilterViewEdit.php
index d4f6cc1..4f10be0 100644
--- a/includes/Views/AbuseFilterViewEdit.php
+++ b/includes/Views/AbuseFilterViewEdit.php
@@ -527,18 +527,28 @@
}
 
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' )
+   

[MediaWiki-commits] [Gerrit] mediawiki...AbuseFilter[master]: Fix confusing warning message on throtthled filters

2017-09-05 Thread Dmaza (Code Review)
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 

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