Merge "PurgeOldLogIPData.php: Minor doc and code clean up"

This commit is contained in:
jenkins-bot 2022-09-27 14:09:32 +00:00 committed by Gerrit Code Review
commit 1744abb0c7

View file

@ -3,9 +3,8 @@
namespace MediaWiki\Extension\AbuseFilter\Maintenance;
// @codeCoverageIgnoreStart
if ( getenv( 'MW_INSTALL_PATH' ) ) {
$IP = getenv( 'MW_INSTALL_PATH' );
} else {
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
}
require_once "$IP/maintenance/Maintenance.php";
@ -18,7 +17,7 @@ use MWTimestamp;
class PurgeOldLogIPData extends Maintenance {
public function __construct() {
parent::__construct();
$this->addDescription( 'Purge old IP Address data from AbuseFilter logs' );
$this->addDescription( 'Purge old IP address data from the abuse_filter_log table' );
$this->setBatchSize( 200 );
$this->requireExtension( 'Abuse Filter' );
@ -28,7 +27,7 @@ class PurgeOldLogIPData extends Maintenance {
* @inheritDoc
*/
public function execute() {
$this->output( "Purging old IP Address data from abuse_filter_log...\n" );
$this->output( "Purging old data from abuse_filter_log...\n" );
$dbw = wfGetDB( DB_PRIMARY );
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$cutoffUnix = (int)MWTimestamp::now( TS_UNIX ) - $this->getConfig()->get( 'AbuseFilterLogIPMaxAge' );