Add newline to echo call
[lhc/web/wiklou.git] / maintenance / cleanupTable.inc
index 265eca9..75699c5 100644 (file)
@@ -2,6 +2,9 @@
 
 require_once( 'FiveUpgrade.inc' );
 
+/**
+ * @ingroup Maintenance
+ */
 abstract class TableCleanup extends FiveUpgrade {
        function __construct( $table, $dryrun = false ) {
                parent::__construct();
@@ -44,9 +47,8 @@ abstract class TableCleanup extends FiveUpgrade {
                $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,
@@ -59,21 +61,19 @@ abstract class TableCleanup extends FiveUpgrade {
        }
 
        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 ) {
@@ -83,5 +83,3 @@ abstract class TableCleanup extends FiveUpgrade {
        abstract function processPage( $row );
        
 }
-
-?>
\ No newline at end of file