require_once( 'FiveUpgrade.inc' );
+/**
+ * @ingroup Maintenance
+ */
abstract class TableCleanup extends FiveUpgrade {
function __construct( $table, $dryrun = false ) {
parent::__construct();
$estimatedTotalTime = $delta / $portion;
$eta = $this->startTime + $estimatedTotalTime;
- global $wgDBname;
printf( "%s %s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n",
- $wgDBname,
+ wfWikiID(),
wfTimestamp( TS_DB, intval( $now ) ),
$portion * 100.0,
$this->table,
}
function runTable( $table, $where, $callback ) {
- $fname = 'CapsCleanup::buildTable';
-
- $count = $this->dbw->selectField( $table, 'count(*)', '', $fname );
+ $count = $this->dbw->selectField( $table, 'count(*)', '', __METHOD__ );
$this->init( $count, $table );
$this->log( "Processing $table..." );
$tableName = $this->dbr->tableName( $table );
$sql = "SELECT * FROM $tableName $where";
- $result = $this->dbr->query( $sql, $fname );
+ $result = $this->dbr->query( $sql, __METHOD__ );
- while( $row = $this->dbr->fetchObject( $result ) ) {
- $updated = call_user_func( $callback, $row );
+ foreach( $result as $row ) {
+ call_user_func( $callback, $row );
}
$this->log( "Finished $table... $this->updated of $this->processed rows updated" );
- $this->dbr->freeResult( $result );
+ $result->free();
}
function hexChar( $matches ) {
abstract function processPage( $row );
}
-
-?>
\ No newline at end of file