r47221 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47220‎ | r47221 | r47222 >
Date:18:30, 13 February 2009
Author:werdna
Status:deferred
Tags:
Comment:
Fix silly fatal
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -762,34 +762,33 @@
763763 global $wgAbuseFilterEmergencyDisableThreshold, $wgAbuseFilterEmergencyDisableCount,
764764 $wgAbuseFilterEmergencyDisableAge, $wgMemc;
765765
766 - foreach( $filters as $filter => $matched ) {
767 - if ($matched) {
768 - // Increment counter
769 - $matchCount = $wgMemc->get( self::filterMatchesKey( $filter ) );
 766+ foreach( $filters as $filter ) {
 767+ // Increment counter
 768+ $matchCount = $wgMemc->get( self::filterMatchesKey( $filter ) );
770769
771 - // Handle missing keys...
772 - if (!$matchCount) {
773 - $wgMemc->set( self::filterMatchesKey( $filter ), 1, self::$statsStoragePeriod );
774 - } else {
775 - $wgMemc->incr( self::filterMatchesKey( $filter ) );
776 - }
777 - $matchCount++;
778 -
779 - // Figure out if the filter is subject to being deleted.
780 - $filter_age = wfTimestamp( TS_UNIX, self::$filters[$filter]->af_timestamp );
781 - $throttle_exempt_time = $filter_age + $wgAbuseFilterEmergencyDisableAge;
 770+ // Handle missing keys...
 771+ if (!$matchCount) {
 772+ $wgMemc->set( self::filterMatchesKey( $filter ), 1, self::$statsStoragePeriod );
 773+ } else {
 774+ $wgMemc->incr( self::filterMatchesKey( $filter ) );
 775+ }
 776+ $matchCount++;
 777+
 778+ // Figure out if the filter is subject to being deleted.
 779+ $filter_age = wfTimestamp( TS_UNIX,
 780+ self::$filters[$filter]->af_timestamp );
 781+ $throttle_exempt_time = $filter_age + $wgAbuseFilterEmergencyDisableAge;
782782
783 - if ($total && $throttle_exempt_time > time()
784 - && $matchCount > $wgAbuseFilterEmergencyDisableCount
785 - && ($matchCount / $total) > $wgAbuseFilterEmergencyDisableThreshold)
786 - {
787 - // More than $wgAbuseFilterEmergencyDisableCount matches,
788 - // constituting more than $wgAbuseFilterEmergencyDisableThreshold
789 - // (a fraction) of last few edits. Disable it.
790 - $dbw = wfGetDB( DB_MASTER );
791 - $dbw->update( 'abuse_filter', array( 'af_throttled' => 1 ),
792 - array( 'af_id' => $filter ), __METHOD__ );
793 - }
 783+ if ($total && $throttle_exempt_time > time()
 784+ && $matchCount > $wgAbuseFilterEmergencyDisableCount
 785+ && ($matchCount / $total) > $wgAbuseFilterEmergencyDisableThreshold)
 786+ {
 787+ // More than $wgAbuseFilterEmergencyDisableCount matches,
 788+ // constituting more than $wgAbuseFilterEmergencyDisableThreshold
 789+ // (a fraction) of last few edits. Disable it.
 790+ $dbw = wfGetDB( DB_MASTER );
 791+ $dbw->update( 'abuse_filter', array( 'af_throttled' => 1 ),
 792+ array( 'af_id' => $filter ), __METHOD__ );
794793 }
795794 }
796795 }

Status & tagging log