Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92266
Change subject: Only allow throttling if object caching is enabled...
......................................................................
Only allow throttling if object caching is enabled...
...otherwise it doesn't work.
This change add 2 checks for object caching, one for the filter
configuration interface, and one for the actual throttle checking.
Bug: 50894
Change-Id: I89ebcc6ff7d91d3a9ad8e744c0c4ff3e33e3b673
---
M AbuseFilter.class.php
M Views/AbuseFilterViewEdit.php
2 files changed, 46 insertions(+), 38 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/66/92266/1
diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php
index 61939ce..2444562 100644
--- a/AbuseFilter.class.php
+++ b/AbuseFilter.class.php
@@ -702,6 +702,7 @@
* the errors and warnings to be shown to the user to explain
the actions.
*/
public static function executeFilterActions( $filters, $title, $vars ) {
+ global $wgMainCacheType;
wfProfileIn( __METHOD__ );
$actionsByFilter = self::getConsequencesForFilters( $filters );
@@ -717,7 +718,9 @@
$global_filter = ( preg_match( '/^global-/', $filter )
== 1);
- if ( !empty( $actions['throttle'] ) ) {
+ // If the filter is throttled and throttling is
available via object
+ // caching, check to see if the user has hit the
throttle.
+ if ( !empty( $actions['throttle'] ) && $wgMainCacheType
) {
$parameters =
$actions['throttle']['parameters'];
$throttleId = array_shift( $parameters );
list( $rateCount, $ratePeriod ) = explode( ',',
array_shift( $parameters ) );
diff --git a/Views/AbuseFilterViewEdit.php b/Views/AbuseFilterViewEdit.php
index 155d5e3..6a15bcd 100644
--- a/Views/AbuseFilterViewEdit.php
+++ b/Views/AbuseFilterViewEdit.php
@@ -581,7 +581,7 @@
* @return string
*/
function buildConsequenceSelector( $action, $set, $parameters, $row ) {
- global $wgAbuseFilterAvailableActions;
+ global $wgAbuseFilterAvailableActions, $wgMainCacheType;
if ( !in_array( $action, $wgAbuseFilterAvailableActions ) ) {
return '';
@@ -597,45 +597,50 @@
switch( $action ) {
case 'throttle':
- $throttleSettings = Xml::checkLabel(
- $this->msg(
'abusefilter-edit-action-throttle' )->text(),
- 'wpFilterActionThrottle',
-
"mw-abusefilter-action-checkbox-$action",
- $set,
- array( 'class' =>
'mw-abusefilter-action-checkbox' ) + $cbReadOnlyAttrib );
- $throttleFields = array();
-
- if ( $set ) {
- array_shift( $parameters );
- $throttleRate = explode( ',',
$parameters[0] );
- $throttleCount = $throttleRate[0];
- $throttlePeriod = $throttleRate[1];
-
- $throttleGroups = implode( "\n",
array_slice( $parameters, 1 ) );
+ // Throttling is only available via object
caching
+ if ( !$wgMainCacheType ) {
+ return '';
} else {
- $throttleCount = 3;
- $throttlePeriod = 60;
+ $throttleSettings = Xml::checkLabel(
+ $this->msg(
'abusefilter-edit-action-throttle' )->text(),
+ 'wpFilterActionThrottle',
+
"mw-abusefilter-action-checkbox-$action",
+ $set,
+ array( 'class' =>
'mw-abusefilter-action-checkbox' ) + $cbReadOnlyAttrib );
+ $throttleFields = array();
- $throttleGroups = "user\n";
+ if ( $set ) {
+ array_shift( $parameters );
+ $throttleRate = explode( ',',
$parameters[0] );
+ $throttleCount =
$throttleRate[0];
+ $throttlePeriod =
$throttleRate[1];
+
+ $throttleGroups = implode(
"\n", array_slice( $parameters, 1 ) );
+ } else {
+ $throttleCount = 3;
+ $throttlePeriod = 60;
+
+ $throttleGroups = "user\n";
+ }
+
+
$throttleFields['abusefilter-edit-throttle-count'] =
+ Xml::input(
'wpFilterThrottleCount', 20, $throttleCount, $readOnlyAttrib );
+
$throttleFields['abusefilter-edit-throttle-period'] =
+ $this->msg(
'abusefilter-edit-throttle-seconds' )
+ ->rawParams( Xml::input(
'wpFilterThrottlePeriod', 20, $throttlePeriod,
+ $readOnlyAttrib )
+ )->parse();
+
$throttleFields['abusefilter-edit-throttle-groups'] =
+ Xml::textarea(
'wpFilterThrottleGroups', $throttleGroups . "\n",
+
40, 5, $readOnlyAttrib );
+ $throttleSettings .=
+ Xml::tags(
+ 'div',
+ array( 'id' =>
'mw-abusefilter-throttle-parameters' ),
+ Xml::buildForm(
$throttleFields )
+ );
+ return $throttleSettings;
}
-
-
$throttleFields['abusefilter-edit-throttle-count'] =
- Xml::input( 'wpFilterThrottleCount',
20, $throttleCount, $readOnlyAttrib );
-
$throttleFields['abusefilter-edit-throttle-period'] =
- $this->msg(
'abusefilter-edit-throttle-seconds' )
- ->rawParams( Xml::input(
'wpFilterThrottlePeriod', 20, $throttlePeriod,
- $readOnlyAttrib )
- )->parse();
-
$throttleFields['abusefilter-edit-throttle-groups'] =
- Xml::textarea(
'wpFilterThrottleGroups', $throttleGroups . "\n",
- 40, 5,
$readOnlyAttrib );
- $throttleSettings .=
- Xml::tags(
- 'div',
- array( 'id' =>
'mw-abusefilter-throttle-parameters' ),
- Xml::buildForm( $throttleFields
)
- );
- return $throttleSettings;
case 'flag':
$checkbox = Xml::checkLabel(
$this->msg(
'abusefilter-edit-action-flag' )->text(),
--
To view, visit https://gerrit.wikimedia.org/r/92266
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I89ebcc6ff7d91d3a9ad8e744c0c4ff3e33e3b673
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits