class CompressOld extends Maintenance {
/**
* Option to load each revision individually.
- *
*/
const LS_INDIVIDUAL = 0;
/**
* Option to load revisions in chunks.
- *
*/
const LS_CHUNKED = 1;
public function execute() {
global $wgDBname;
if ( !function_exists( "gzdeflate" ) ) {
- $this->error( "You must enable zlib support in PHP to compress old revisions!\n" .
- "Please see http://www.php.net/manual/en/ref.zlib.php\n", true );
+ $this->fatalError( "You must enable zlib support in PHP to compress old revisions!\n" .
+ "Please see http://www.php.net/manual/en/ref.zlib.php\n" );
}
$type = $this->getOption( 'type', 'concat' );
) {
$loadStyle = self::LS_CHUNKED;
- $dbr = $this->getDB( DB_SLAVE );
+ $dbr = $this->getDB( DB_REPLICA );
$dbw = $this->getDB( DB_MASTER );
# Set up external storage
$usedChunk = false;
$primaryOldid = $revs[$i]->rev_text_id;
- // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning
# Get the text of each revision and add it to the object
+ // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
for ( $j = 0; $j < $thisChunkSize && $chunk->isHappy(); $j++ ) {
- // @codingStandardsIgnoreEnd
$oldid = $revs[$i + $j]->rev_text_id;
# Get text
if ( $text === false ) {
$this->error( "\nError, unable to get text in old_id $oldid" );
- # $dbw->delete( 'old', array( 'old_id' => $oldid ) );
+ # $dbw->delete( 'old', [ 'old_id' => $oldid ] );
}
if ( $extdb == "" && $j == 0 ) {
$this->output( "/" );
$this->commitTransaction( $dbw, __METHOD__ );
$i += $thisChunkSize;
- wfWaitForSlaves();
}
$this->output( "\n" );
}
}
}
-$maintClass = 'CompressOld';
+$maintClass = CompressOld::class;
require_once RUN_MAINTENANCE_IF_MAIN;