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
This commit is contained in:
Bartosz Dziewoński 2016-04-08 19:43:02 +02:00
parent 337cad30d9
commit ca0b0c081d

View file

@ -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 );