Revision: 45996
Author:   werdna
Date:     2009-01-22 02:01:48 +0000 (Thu, 22 Jan 2009)

Log Message:
-----------
Re-implement condition counter, and fix a parse error.

Modified Paths:
--------------
    branches/change-tagging/extensions/AbuseFilter/AbuseFilter.class.php
    branches/change-tagging/extensions/AbuseFilter/AbuseFilter.i18n.php
    branches/change-tagging/extensions/AbuseFilter/AbuseFilter.parser.php
    branches/change-tagging/extensions/AbuseFilter/AbuseFilter.php

Modified: branches/change-tagging/extensions/AbuseFilter/AbuseFilter.class.php
===================================================================
--- branches/change-tagging/extensions/AbuseFilter/AbuseFilter.class.php        
2009-01-22 02:01:27 UTC (rev 45995)
+++ branches/change-tagging/extensions/AbuseFilter/AbuseFilter.class.php        
2009-01-22 02:01:48 UTC (rev 45996)
@@ -41,6 +41,16 @@
                }
        }
 
+       public static function triggerLimiter( $val = 1 ) {
+               self::$condCount += $val;
+
+               global $wgAbuseFilterConditionLimit;
+
+               if (self::$condCount > $wgAbuseFilterConditionLimit) {
+                       throw new MWException( "Condition limit reached." );
+               }
+       }
+
        public static function disableConditionLimit() {
                // For use in batch scripts and the like
                self::$condLimitEnabled = false;
@@ -165,7 +175,6 @@
                                $newLog['afl_filter'] = $row->af_id;
                                $newLog['afl_action'] = $vars['ACTION'];
 
-                               if ($
                                $log_entries[] = $newLog;
                                
                                $doneActionsByFilter[$row->af_id] = array();

Modified: branches/change-tagging/extensions/AbuseFilter/AbuseFilter.i18n.php
===================================================================
--- branches/change-tagging/extensions/AbuseFilter/AbuseFilter.i18n.php 
2009-01-22 02:01:27 UTC (rev 45995)
+++ branches/change-tagging/extensions/AbuseFilter/AbuseFilter.i18n.php 
2009-01-22 02:01:48 UTC (rev 45996)
@@ -119,7 +119,7 @@
        'abusefilter-reautoconfirm-notallowed' => 'You are not allowed to 
restore autoconfirmed status.',
        
        // Abuse filter status
-       'abusefilter-status' => "Of the last $1 {{PLURAL:$1|action|actions}}, 
$5 ($6%) {{PLURAL:$5|has|have}} matched one of the filters currently enabled.", 
// $2 ($3%) {{PLURAL:$2|has|have}} reached the condition limit of $4.
+       'abusefilter-status' => "Of the last $1 {{PLURAL:$1|action|actions}}, 
$2 ($3%) {{PLURAL:$2|has|have}} reached the condition limit of $4, and $5 ($6%) 
{{PLURAL:$5|has|have}} matched one of the filters currently enabled.",
        
        // The edit screen
        'abusefilter-edit-subtitle' => 'Editing filter $1',

Modified: branches/change-tagging/extensions/AbuseFilter/AbuseFilter.parser.php
===================================================================
--- branches/change-tagging/extensions/AbuseFilter/AbuseFilter.parser.php       
2009-01-22 02:01:27 UTC (rev 45995)
+++ branches/change-tagging/extensions/AbuseFilter/AbuseFilter.parser.php       
2009-01-22 02:01:48 UTC (rev 45996)
@@ -438,6 +438,7 @@
        }
        
        protected function doLevelCompares( &$result ) {
+               AbuseFilter::triggerLimiter();
                $this->doLevelSumRels( $result );
                $ops = array( '==', '===', '!=', '!==', '<', '>', '<=', '>=', 
'=' );
                while( $this->mCur->type == AFPToken::TOp && in_array( 
$this->mCur->value, $ops ) ) {
@@ -577,6 +578,7 @@
                        if (isset(self::$funcCache[$funcHash])) {
                                $result = self::$funcCache[$funcHash];
                        } else {
+                               AbuseFilter::triggerLimiter();
                                $result = self::$funcCache[$funcHash] = 
$this->$func( $args );
                        }
                        

Modified: branches/change-tagging/extensions/AbuseFilter/AbuseFilter.php
===================================================================
--- branches/change-tagging/extensions/AbuseFilter/AbuseFilter.php      
2009-01-22 02:01:27 UTC (rev 45995)
+++ branches/change-tagging/extensions/AbuseFilter/AbuseFilter.php      
2009-01-22 02:01:48 UTC (rev 45996)
@@ -56,7 +56,7 @@
 
 // Conditions take about 4ms to check, so 100 conditions would take 400ms
 // Currently, has no effect.
-// $wgAbuseFilterConditionLimit = 1000;
+$wgAbuseFilterConditionLimit = 0;
 
 // Disable filters if they match more than X edits, constituting more than Y% 
of the last Z edits, if they have been changed in the last S seconds
 $wgAbuseFilterEmergencyDisableThreshold = 0.05;



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to