Index: trunk/extensions/AbuseFilter/AbuseFilter.php |
— | — | @@ -84,3 +84,4 @@ |
85 | 85 | $wgAbuseFilterStyleVersion = 2; |
86 | 86 | |
87 | 87 | $wgAbuseFilterRestrictedActions = array( 'block', 'degroup' ); |
| 88 | + |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -192,14 +192,19 @@ |
193 | 193 | public static function executeFilterActions( $filters, $title, $vars ) { |
194 | 194 | $dbr = wfGetDB( DB_SLAVE ); |
195 | 195 | // Retrieve the consequences. |
196 | | - $res = $dbr->select( 'abuse_filter_action', '*', array( 'afa_filter' => $filters ), __METHOD__ ); |
| 196 | + $res = $dbr->select( array('abuse_filter_action', 'abuse_filter'), '*', array( 'af_id' => $filters ), __METHOD__, array(), array( 'abuse_filter_action' => array('LEFT JOIN', 'afa_filter=af_id') ) ); |
197 | 197 | |
198 | 198 | $actionsByFilter = array_fill_keys( $filters, array() ); |
199 | 199 | $actionsTaken = array_fill_keys( $filters, array() ); |
200 | 200 | |
201 | 201 | // Categorise consequences by filter. |
| 202 | + global $wgAbuseFilterRestrictedActions; |
202 | 203 | while ( $row = $dbr->fetchObject( $res ) ) { |
203 | | - $actionsByFilter[$row->afa_filter][$row->afa_consequence] = array( 'action' => $row->afa_consequence, 'parameters' => explode( "\n", $row->afa_parameters ) ); |
| 204 | + if ( $row->af_throttled && in_array( $row->afa_consequence, $wgAbuseFilterRestrictedActions ) ) { |
| 205 | + ## Don't do the action |
| 206 | + } else { |
| 207 | + $actionsByFilter[$row->afa_filter][$row->afa_consequence] = array( 'action' => $row->afa_consequence, 'parameters' => explode( "\n", $row->afa_parameters ) ); |
| 208 | + } |
204 | 209 | } |
205 | 210 | |
206 | 211 | wfLoadExtensionMessages( 'AbuseFilter' ); |
— | — | @@ -560,7 +565,7 @@ |
561 | 566 | return; // The rest will only apply if a filter was triggered. |
562 | 567 | } |
563 | 568 | |
564 | | - self::checkEmergencyDisable( $filters ); |
| 569 | + self::checkEmergencyDisable( $filters, $total ); |
565 | 570 | |
566 | 571 | // Increment trigger counter |
567 | 572 | if ($filter_triggered) { |
— | — | @@ -573,7 +578,7 @@ |
574 | 579 | $dbw->update( 'abuse_filter', array( 'af_hit_count=af_hit_count+1' ), array( 'af_id' => array_keys( array_filter( $filters ) ) ), __METHOD__ ); |
575 | 580 | } |
576 | 581 | |
577 | | - public static function checkEmergencyDisable( $filters ) { |
| 582 | + public static function checkEmergencyDisable( $filters, $total ) { |
578 | 583 | global $wgAbuseFilterEmergencyDisableThreshold, $wgAbuseFilterEmergencyDisableCount, $wgAbuseFilterEmergencyDisableAge, $wgMemc; |
579 | 584 | |
580 | 585 | foreach( $filters as $filter => $matched ) { |
— | — | @@ -593,10 +598,10 @@ |
594 | 599 | $filter_age = wfTimestamp( TS_UNIX, self::$filters[$filter]->af_timestamp ); |
595 | 600 | $throttle_exempt_time = $filter_age + $wgAbuseFilterEmergencyDisableAge; |
596 | 601 | |
597 | | - if ($throttle_exempt_time > time() && $matchCount > $wgAbuseFilterEmergencyDisableCount && ($matchCount / $total) > $wgAbuseFilterEmergencyDisableThreshold) { |
| 602 | + if ($total && $throttle_exempt_time > time() && $matchCount > $wgAbuseFilterEmergencyDisableCount && ($matchCount / $total) > $wgAbuseFilterEmergencyDisableThreshold) { |
598 | 603 | // More than $wgAbuseFilterEmergencyDisableCount matches, constituting more than $wgAbuseFilterEmergencyDisableThreshold (a fraction) of last few edits. Disable it. |
599 | 604 | $dbw = wfGetDB( DB_MASTER ); |
600 | | - $dbw->update( 'abuse_filter', array( 'af_enabled' => 0, 'af_throttled' => 1 ), array( 'af_id' => $filter ), __METHOD__ ); |
| 605 | + $dbw->update( 'abuse_filter', array( 'af_throttled' => 1 ), array( 'af_id' => $filter ), __METHOD__ ); |
601 | 606 | } |
602 | 607 | } |
603 | 608 | } |