mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 22:15:26 +00:00
b7fa8d5d20
Display running count. Silent scripts are annoying Change-Id: I4dcebbf1cd49dce6332ed1bdc0e2ba7aced4b8f1
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
if ( getenv( 'MW_INSTALL_PATH' ) ) {
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
} else {
|
|
$IP = dirname( __FILE__ ) . '/../../..';
|
|
}
|
|
require_once( "$IP/maintenance/Maintenance.php" );
|
|
|
|
class PurgeOldLogIPData extends Maintenance {
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->mDescription = "Purge old IP Address data from AbuseFilter logs";
|
|
$this->setBatchSize( 200 );
|
|
}
|
|
|
|
public function execute() {
|
|
global $wgAbuseFilterLogIPMaxAge;
|
|
|
|
$this->output( "Purging old IP Address data from abuse_filter_log...\n" );
|
|
$dbw = wfGetDB( DB_MASTER );
|
|
|
|
$count = 0;
|
|
while ( true ) {
|
|
$dbw->begin();
|
|
$dbw->update(
|
|
'abuse_filter_log',
|
|
array( 'afl_ip' => '' ),
|
|
array(
|
|
'afl_ip <> ""',
|
|
"afl_timestamp < " . $dbw->addQuotes( $dbw->timestamp( time() - $wgAbuseFilterLogIPMaxAge ) )
|
|
),
|
|
__METHOD__,
|
|
array( 'LIMIT' => $this->mBatchSize )
|
|
);
|
|
$count += $dbw->affectedRows();
|
|
$dbw->commit();
|
|
if ( $dbw->affectedRows() < $this->mBatchSize ) {
|
|
break; // all updated
|
|
}
|
|
$this->output( "$count\n" );
|
|
|
|
wfWaitForSlaves();
|
|
}
|
|
|
|
$this->output( "$count rows.\n" );
|
|
|
|
$this->output( "Done.\n" );
|
|
}
|
|
|
|
}
|
|
|
|
$maintClass = "PurgeOldLogIPData";
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|