jenkins-bot has submitted this change and it was merged.

Change subject: Mostly unbreak profiling of number of conditions used by filters
......................................................................


Mostly unbreak profiling of number of conditions used by filters

We were only recording the total number of conditions used by all filters,
then treating it as if it was the per-filter number, resulting in crazy
stupid values. We were also not clearing this when a filter was edited.

(This does not fix the remaining problems mentioned on the task.)

Bug: T53294
Change-Id: I4f9f88f94469b977fe60c554b76e94edacac3462
---
M AbuseFilter.class.php
1 file changed, 9 insertions(+), 7 deletions(-)

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



diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php
index 92dd2f8..a10ede0 100644
--- a/AbuseFilter.class.php
+++ b/AbuseFilter.class.php
@@ -569,9 +569,11 @@
                global $wgMemc;
                $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'count' );
                $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'total' );
+               $condsKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'conds' );
 
                $wgMemc->delete( $countKey );
                $wgMemc->delete( $totalKey );
+               $wgMemc->delete( $condsKey );
        }
 
        /**
@@ -584,20 +586,20 @@
 
                $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'count' );
                $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'total' );
-               $totalCondKey = wfMemcKey( 'abusefilter', 'profile-conds', 
'total' );
+               $condsKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'conds' );
 
                $curCount = $wgMemc->get( $countKey );
                $curTotal = $wgMemc->get( $totalKey );
-               $curTotalConds = $wgMemc->get( $totalCondKey );
+               $curConds = $wgMemc->get( $condsKey );
 
                if ( $curCount ) {
-                       $wgMemc->set( $totalCondKey, $curTotalConds + $conds, 
3600 );
+                       $wgMemc->set( $condsKey, $curConds + $conds, 3600 );
                        $wgMemc->set( $totalKey, $curTotal + $time, 3600 );
                        $wgMemc->incr( $countKey );
                } else {
                        $wgMemc->set( $countKey, 1, 3600 );
                        $wgMemc->set( $totalKey, $time, 3600 );
-                       $wgMemc->set( $totalCondKey, $conds, 3600 );
+                       $wgMemc->set( $condsKey, $conds, 3600 );
                }
        }
 
@@ -610,11 +612,11 @@
 
                $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'count' );
                $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'total' );
-               $totalCondKey = wfMemcKey( 'abusefilter', 'profile-conds', 
'total' );
+               $condsKey = wfMemcKey( 'abusefilter', 'profile', $filter, 
'conds' );
 
                $curCount = $wgMemc->get( $countKey );
                $curTotal = $wgMemc->get( $totalKey );
-               $curTotalConds = $wgMemc->get( $totalCondKey );
+               $curConds = $wgMemc->get( $condsKey );
 
                if ( !$curCount ) {
                        return array( 0, 0 );
@@ -623,7 +625,7 @@
                $timeProfile = ( $curTotal / $curCount ) * 1000; // 1000 ms in 
a sec
                $timeProfile = round( $timeProfile, 2 ); // Return in ms, 
rounded to 2dp
 
-               $condProfile = ( $curTotalConds / $curCount );
+               $condProfile = ( $curConds / $curCount );
                $condProfile = round( $condProfile, 0 );
 
                return array( $timeProfile, $condProfile );

-- 
To view, visit https://gerrit.wikimedia.org/r/282399
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4f9f88f94469b977fe60c554b76e94edacac3462
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <matma....@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Se4598 <se4...@gmx.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to