mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-24 02:38:16 +00:00
Replace wfDebug and wfDebugLog with logger
Per standard on https://www.mediawiki.org/wiki/Manual:Structured_logging. The use inside AbuseFilterParser is removed in Ie55746bb7731062ae2d46d84857af2a05d78cf4c. Change-Id: Ia62287c4ff5f904557cd6d43d47a9f4d9696b94b
This commit is contained in:
parent
9270ee5280
commit
2f0a0a0893
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Wikimedia\Rdbms\Database;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
|
||||
class AFComputedVariable {
|
||||
public $mMethod, $mParameters;
|
||||
|
@ -62,7 +63,8 @@ class AFComputedVariable {
|
|||
return self::$userCache[$username];
|
||||
}
|
||||
|
||||
wfDebug( "Couldn't find user $username in cache\n" );
|
||||
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
|
||||
$logger->debug( "Couldn't find user $username in cache" );
|
||||
}
|
||||
|
||||
if ( count( self::$userCache ) > 1000 ) {
|
||||
|
@ -102,7 +104,8 @@ class AFComputedVariable {
|
|||
self::$articleCache = [];
|
||||
}
|
||||
|
||||
wfDebug( "Creating article object for $namespace:$title in cache\n" );
|
||||
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
|
||||
$logger->debug( "Creating article object for $namespace:$title in cache" );
|
||||
|
||||
// TODO: use WikiPage instead!
|
||||
$t = Title::makeTitle( $namespace, $title );
|
||||
|
@ -223,11 +226,12 @@ class AFComputedVariable {
|
|||
$parameters['title']
|
||||
);
|
||||
|
||||
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
|
||||
if ( $vars->getVar( 'context' )->toString() == 'filter' ) {
|
||||
$links = $this->getLinksFromDB( $article );
|
||||
wfDebug( "AbuseFilter: loading old links from DB\n" );
|
||||
$logger->debug( 'Loading old links from DB' );
|
||||
} elseif ( $article->getContentModel() === CONTENT_MODEL_WIKITEXT ) {
|
||||
wfDebug( "AbuseFilter: loading old links from Parser\n" );
|
||||
$logger->debug( 'Loading old links from Parser' );
|
||||
$textVar = $parameters['text-var'];
|
||||
|
||||
$wikitext = $vars->getVar( $textVar )->toString();
|
||||
|
|
|
@ -525,7 +525,8 @@ class AbuseFilter {
|
|||
} catch ( Exception $excep ) {
|
||||
$result = false;
|
||||
|
||||
wfDebugLog( 'AbuseFilter', 'AbuseFilter parser error: ' . $excep->getMessage() . "\n" );
|
||||
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
|
||||
$logger->debug( 'AbuseFilter parser error: ' . $excep->getMessage() );
|
||||
|
||||
if ( !$ignoreError ) {
|
||||
throw $excep;
|
||||
|
@ -1712,7 +1713,8 @@ class AbuseFilter {
|
|||
$message = [ $msg ];
|
||||
}
|
||||
} else {
|
||||
wfDebugLog( 'AbuseFilter', "Unrecognised action $action" );
|
||||
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
|
||||
$logger->debug( "Unrecognised action $action" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1811,26 +1813,27 @@ class AbuseFilter {
|
|||
$key = self::throttleKey( $throttleId, $types, $title, $global );
|
||||
$count = intval( $stash->get( $key ) );
|
||||
|
||||
wfDebugLog( 'AbuseFilter', "Got value $count for throttle key $key\n" );
|
||||
$logger = LoggerFactory::getInstance( 'AbuseFilter' );
|
||||
$logger->debug( "Got value $count for throttle key $key" );
|
||||
|
||||
if ( $count > 0 ) {
|
||||
$stash->incr( $key );
|
||||
$count++;
|
||||
wfDebugLog( 'AbuseFilter', "Incremented throttle key $key" );
|
||||
$logger->debug( "Incremented throttle key $key" );
|
||||
} else {
|
||||
wfDebugLog( 'AbuseFilter', "Added throttle key $key with value 1" );
|
||||
$logger->debug( "Added throttle key $key with value 1" );
|
||||
$stash->add( $key, 1, $ratePeriod );
|
||||
$count = 1;
|
||||
}
|
||||
|
||||
if ( $count > $rateCount ) {
|
||||
wfDebugLog( 'AbuseFilter', "Throttle $key hit value $count -- maximum is $rateCount." );
|
||||
$logger->debug( "Throttle $key hit value $count -- maximum is $rateCount." );
|
||||
|
||||
// THROTTLED
|
||||
return true;
|
||||
}
|
||||
|
||||
wfDebugLog( 'AbuseFilter', "Throttle $key not hit!" );
|
||||
$logger->debug( "Throttle $key not hit!" );
|
||||
|
||||
// NOT THROTTLED
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue