X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupTable.inc;h=75699c52ca97ff34017babca691952a359ce2eb7;hb=9c8e5796c8a906e79dd63d212bb994e24b72debe;hp=cf33e8f081e431261f844b1e5471fbea7fdf9524;hpb=a78478c449cc53d9459ed669423e1e4d7d206f6f;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index cf33e8f081..75699c52ca 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -2,6 +2,9 @@ require_once( 'FiveUpgrade.inc' ); +/** + * @ingroup Maintenance + */ abstract class TableCleanup extends FiveUpgrade { function __construct( $table, $dryrun = false ) { parent::__construct(); @@ -58,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 ) ) { + 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 ) { @@ -82,5 +83,3 @@ abstract class TableCleanup extends FiveUpgrade { abstract function processPage( $row ); } - -?>