*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
public function execute() {
$dbw = wfGetDB( DB_MASTER );
$rl = new ResourceLoader();
public function execute() {
$dbw = wfGetDB( DB_MASTER );
$rl = new ResourceLoader();
$moduleList = implode( ', ', array_map( array( $dbw, 'addQuotes' ), $moduleNames ) );
$limit = max( 1, intval( $this->getOption( 'batchsize', 500 ) ) );
$maxlag = intval( $this->getOption( 'max-slave-lag', 5 ) );
$moduleList = implode( ', ', array_map( array( $dbw, 'addQuotes' ), $moduleNames ) );
$limit = max( 1, intval( $this->getOption( 'batchsize', 500 ) ) );
$maxlag = intval( $this->getOption( 'max-slave-lag', 5 ) );
do {
// $dbw->delete() doesn't support LIMIT :(
$where = $moduleList ? "md_module NOT IN ($moduleList)" : '1=1';
do {
// $dbw->delete() doesn't support LIMIT :(
$where = $moduleList ? "md_module NOT IN ($moduleList)" : '1=1';
$numRows = $dbw->affectedRows();
$this->output( "Batch $i: $numRows rows\n" );
$i++;
wfWaitForSlaves( $maxlag );
} while( $numRows > 0 );
$this->output( "done\n" );
$numRows = $dbw->affectedRows();
$this->output( "Batch $i: $numRows rows\n" );
$i++;
wfWaitForSlaves( $maxlag );
} while( $numRows > 0 );
$this->output( "done\n" );
$numRows = $dbw->affectedRows();
$this->output( "Batch $i: $numRows rows\n" );
$i++;
wfWaitForSlaves( $maxlag );
} while( $numRows > 0 );
$this->output( "done\n" );
$numRows = $dbw->affectedRows();
$this->output( "Batch $i: $numRows rows\n" );
$i++;
wfWaitForSlaves( $maxlag );
} while( $numRows > 0 );
$this->output( "done\n" );