From ca0b0c081d485f843c7b89f61b53ac8889fa2d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 8 Apr 2016 19:43:02 +0200 Subject: [PATCH] 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 --- AbuseFilter.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php index 92dd2f881..a10ede0b2 100644 --- a/AbuseFilter.class.php +++ b/AbuseFilter.class.php @@ -569,9 +569,11 @@ class AbuseFilter { 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 @@ class AbuseFilter { $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 @@ class AbuseFilter { $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 @@ class AbuseFilter { $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 );