X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FcleanupTable.inc;h=3ace09cb30e7392042623fd96c4adc95a767e805;hp=74073bc5880bd6b8b05d52eeebf70ab74d2e62c9;hb=f5b9af121a07ecc674a63cbc65c3a01e9fa7d785;hpb=c6e300e9f89fe6f9367356b70d42002898e2d681 diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index 74073bc588..3ace09cb30 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -29,12 +29,12 @@ require_once __DIR__ . '/Maintenance.php'; * @ingroup Maintenance */ class TableCleanup extends Maintenance { - protected $defaultParams = array( + protected $defaultParams = [ 'table' => 'page', - 'conds' => array(), + 'conds' => [], 'index' => 'page_id', 'callback' => 'processRow', - ); + ]; protected $dryrun = false; public $batchSize = 100; @@ -54,7 +54,7 @@ class TableCleanup extends Maintenance { $wgUser = User::newFromName( 'Conversion script' ); $this->output( "Checking for bad titles...\n" ); } else { - $wgUser = User::newSystemUser( 'Conversion script', array( 'steal' => true ) ); + $wgUser = User::newSystemUser( 'Conversion script', [ 'steal' => true ] ); $this->output( "Checking and fixing bad titles...\n" ); } $this->runTable( $this->defaultParams ); @@ -106,10 +106,10 @@ class TableCleanup extends Maintenance { * @throws MWException */ public function runTable( $params ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); if ( array_diff( array_keys( $params ), - array( 'table', 'conds', 'index', 'callback' ) ) + [ 'table', 'conds', 'index', 'callback' ] ) ) { throw new MWException( __METHOD__ . ': Missing parameter ' . implode( ', ', $params ) ); } @@ -121,12 +121,12 @@ class TableCleanup extends Maintenance { $this->output( "Processing $table...\n" ); $index = (array)$params['index']; - $indexConds = array(); - $options = array( + $indexConds = []; + $options = [ 'ORDER BY' => implode( ',', $index ), 'LIMIT' => $this->batchSize - ); - $callback = array( $this, $params['callback'] ); + ]; + $callback = [ $this, $params['callback'] ]; while ( true ) { $conds = array_merge( $params['conds'], $indexConds ); @@ -158,7 +158,7 @@ class TableCleanup extends Maintenance { $nextCond = "$field > $encValue OR ($field = $encValue AND ($nextCond))"; } } - $indexConds = array( $nextCond ); + $indexConds = [ $nextCond ]; } $this->output( "Finished $table... $this->updated of $this->processed rows updated\n" );