* @ingroup Maintenance
*/
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
/**
* Generic class to cleanup a database table. Already subclasses Maintenance.
public $batchSize = 100;
public $reportInterval = 100;
+ protected $processed, $updated, $count, $startTime, $table;
+
public function __construct() {
parent::__construct();
$this->addOption( 'dry-run', 'Perform a dry run' );
$this->processed = 0;
$this->updated = 0;
$this->count = $count;
- $this->startTime = wfTime();
+ $this->startTime = microtime( true );
$this->table = $table;
}
+ /**
+ * @param int $updated
+ */
protected function progress( $updated ) {
$this->updated += $updated;
$this->processed++;
$portion = $this->processed / $this->count;
$updateRate = $this->updated / $this->processed;
- $now = wfTime();
+ $now = microtime( true );
$delta = $now - $this->startTime;
$estimatedTotalTime = $delta / $portion;
$eta = $this->startTime + $estimatedTotalTime;
flush();
}
+ /**
+ * @param array $params
+ * @throws MWException
+ */
public function runTable( $params ) {
$dbr = wfGetDB( DB_SLAVE );
if ( array_diff( array_keys( $params ),
- array( 'table', 'conds', 'index', 'callback' ) ) )
- {
+ array( 'table', 'conds', 'index', 'callback' ) )
+ ) {
throw new MWException( __METHOD__ . ': Missing parameter ' . implode( ', ', $params ) );
}
$this->init( $count, $table );
$this->output( "Processing $table...\n" );
-
$index = (array)$params['index'];
$indexConds = array();
$options = array(
$this->output( "Finished $table... $this->updated of $this->processed rows updated\n" );
}
+ /**
+ * @param array $matches
+ * @return string
+ */
protected function hexChar( $matches ) {
return sprintf( "\\x%02x", ord( $matches[1] ) );
}