mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
Merge "Add $wgAbuseFilterProfile to enable filter profiling"
This commit is contained in:
commit
0ef2bd0dac
|
@ -521,10 +521,12 @@ class AbuseFilter {
|
|||
* @return bool
|
||||
*/
|
||||
public static function checkFilter( $row, $vars, $profile = false, $prefix = '' ) {
|
||||
global $wgAbuseFilterProfile;
|
||||
|
||||
$filterID = $prefix . $row->af_id;
|
||||
|
||||
$startConds = $startTime = null;
|
||||
if ( $profile ) {
|
||||
if ( $profile && $wgAbuseFilterProfile ) {
|
||||
$startConds = self::$condCount;
|
||||
$startTime = microtime( true );
|
||||
}
|
||||
|
@ -548,7 +550,7 @@ class AbuseFilter {
|
|||
$result = false;
|
||||
}
|
||||
|
||||
if ( $profile ) {
|
||||
if ( $profile && $wgAbuseFilterProfile ) {
|
||||
$endTime = microtime( true );
|
||||
$endConds = self::$condCount;
|
||||
|
||||
|
|
|
@ -239,3 +239,6 @@ $wgAbuseFilterDefaultWarningMessage = array(
|
|||
// Age used as cutoff when purging old IP log data.
|
||||
// Used by maintenance script purgeOldLogIPData.php
|
||||
$wgAbuseFilterLogIPMaxAge = 3 * 30 * 24 * 3600; // 3 months
|
||||
|
||||
// Whether to record the time taken and number of conditions used by each filter.
|
||||
$wgAbuseFilterProfile = false;
|
||||
|
|
|
@ -387,17 +387,22 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
|
||||
if ( $filter !== 'new' ) {
|
||||
// Statistics
|
||||
global $wgMemc;
|
||||
global $wgMemc, $wgAbuseFilterProfile;
|
||||
$matches_count = $wgMemc->get( AbuseFilter::filterMatchesKey( $filter ) );
|
||||
$total = $wgMemc->get( AbuseFilter::filterUsedKey( $row->af_group ) );
|
||||
|
||||
if ( $total > 0 ) {
|
||||
$matches_percent = sprintf( '%.2f', 100 * $matches_count / $total );
|
||||
list( $timeProfile, $condProfile ) = AbuseFilter::getFilterProfile( $filter );
|
||||
|
||||
$fields['abusefilter-edit-status-label'] = $this->msg( 'abusefilter-edit-status' )
|
||||
->numParams( $total, $matches_count, $matches_percent, $timeProfile, $condProfile )
|
||||
->escaped();
|
||||
if ( $wgAbuseFilterProfile ) {
|
||||
list( $timeProfile, $condProfile ) = AbuseFilter::getFilterProfile( $filter );
|
||||
$fields['abusefilter-edit-status-label'] = $this->msg( 'abusefilter-edit-status-profile' )
|
||||
->numParams( $total, $matches_count, $matches_percent, $timeProfile, $condProfile )
|
||||
->escaped();
|
||||
} else {
|
||||
$fields['abusefilter-edit-status-label'] = $this->msg( 'abusefilter-edit-status' )
|
||||
->numParams( $total, $matches_count, $matches_percent )
|
||||
->escaped();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,8 @@
|
|||
"abusefilter-edit-subtitle-new": "Creating filter",
|
||||
"abusefilter-edit-oldwarning": "<strong>You are editing an old version of this filter.\nThe statistics quoted are for the most recent version of the filter.\nIf you save your changes, you will overwrite all changes since the revision you are editing.</strong> •\n[[Special:AbuseFilter/history/$2|Return to this filter's history]].",
|
||||
"abusefilter-edit-status-label": "Statistics:",
|
||||
"abusefilter-edit-status": "Of the last $1 {{PLURAL:$1|action|actions}}, this filter has matched $2 ($3%).\nOn average, its run time is $4 ms, and it consumes $5 {{PLURAL:$5|condition|conditions}} of the condition limit.",
|
||||
"abusefilter-edit-status": "Of the last $1 {{PLURAL:$1|action|actions}}, this filter has matched $2 ($3%).",
|
||||
"abusefilter-edit-status-profile": "Of the last $1 {{PLURAL:$1|action|actions}}, this filter has matched $2 ($3%).\nOn average, its run time is $4 ms, and it consumes $5 {{PLURAL:$5|condition|conditions}} of the condition limit.",
|
||||
"abusefilter-edit-throttled": "'''Warning:''' This filter was automatically disabled as a safety measure.\nIt reached the limit of matching more than $1% of actions.",
|
||||
"abusefilter-edit-new": "New filter",
|
||||
"abusefilter-edit-save": "Save filter",
|
||||
|
|
|
@ -158,7 +158,8 @@
|
|||
"abusefilter-edit-subtitle-new": "Page subtitle when creating an abuse filter. Parameters:\n* $1 - (Unused) filter ID\n* $2 - (Unused) history ID\nSee also:\n* {{msg-mw|Abusefilter-edit-subtitle}} - if editing the existing filter",
|
||||
"abusefilter-edit-oldwarning": "Warning displayed when editing an older version of a filter. Parameters:\n* $1 - (Unused) history ID\n* $2 - filter ID",
|
||||
"abusefilter-edit-status-label": "Field label for abuse filter statistics.\n{{Identical|Statistics}}",
|
||||
"abusefilter-edit-status": "Parameters:\n* $1 - number of actions\n* $2 - matched count\n* $3 - matched percentage\n* $4 - time (in milliseconds)\n* $5 - number of conditions",
|
||||
"abusefilter-edit-status": "Parameters:\n* $1 - number of actions\n* $2 - matched count\n* $3 - matched percentage",
|
||||
"abusefilter-edit-status-profile": "Parameters:\n* $1 - number of actions\n* $2 - matched count\n* $3 - matched percentage\n* $4 - time (in milliseconds)\n* $5 - number of conditions",
|
||||
"abusefilter-edit-throttled": "Used as warning message. Parameters:\n* $1 - threshold percentage",
|
||||
"abusefilter-edit-new": "Field value in case an edited filter is new.",
|
||||
"abusefilter-edit-save": "Submit button text to save a filter.",
|
||||
|
|
Loading…
Reference in a new issue