dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Display MediaWiki:Loginprompt on the login page"
[lhc/web/wiklou.git]
/
maintenance
/
cleanupTable.inc
diff --git
a/maintenance/cleanupTable.inc
b/maintenance/cleanupTable.inc
index
85911ba
..
cbd1be6
100644
(file)
--- a/
maintenance/cleanupTable.inc
+++ b/
maintenance/cleanupTable.inc
@@
-21,7
+21,7
@@
* @ingroup Maintenance
*/
* @ingroup Maintenance
*/
-require_once
( __DIR__ . '/Maintenance.php' )
;
+require_once
__DIR__ . '/Maintenance.php'
;
/**
* Generic class to cleanup a database table. Already subclasses Maintenance.
/**
* Generic class to cleanup a database table. Already subclasses Maintenance.
@@
-41,6
+41,8
@@
class TableCleanup extends Maintenance {
public $batchSize = 100;
public $reportInterval = 100;
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' );
public function __construct() {
parent::__construct();
$this->addOption( 'dry-run', 'Perform a dry run' );
@@
-62,10
+64,13
@@
class TableCleanup extends Maintenance {
$this->processed = 0;
$this->updated = 0;
$this->count = $count;
$this->processed = 0;
$this->updated = 0;
$this->count = $count;
- $this->startTime =
wfTime(
);
+ $this->startTime =
microtime( true
);
$this->table = $table;
}
$this->table = $table;
}
+ /**
+ * @param int $updated
+ */
protected function progress( $updated ) {
$this->updated += $updated;
$this->processed++;
protected function progress( $updated ) {
$this->updated += $updated;
$this->processed++;
@@
-75,7
+80,7
@@
class TableCleanup extends Maintenance {
$portion = $this->processed / $this->count;
$updateRate = $this->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;
$delta = $now - $this->startTime;
$estimatedTotalTime = $delta / $portion;
$eta = $this->startTime + $estimatedTotalTime;
@@
-96,12
+101,16
@@
class TableCleanup extends Maintenance {
flush();
}
flush();
}
+ /**
+ * @param array $params
+ * @throws MWException
+ */
public function runTable( $params ) {
$dbr = wfGetDB( DB_SLAVE );
if ( array_diff( array_keys( $params ),
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 ) );
}
throw new MWException( __METHOD__ . ': Missing parameter ' . implode( ', ', $params ) );
}
@@
-111,7
+120,6
@@
class TableCleanup extends Maintenance {
$this->init( $count, $table );
$this->output( "Processing $table...\n" );
$this->init( $count, $table );
$this->output( "Processing $table...\n" );
-
$index = (array)$params['index'];
$indexConds = array();
$options = array(
$index = (array)$params['index'];
$indexConds = array();
$options = array(
@@
-156,6
+164,10
@@
class TableCleanup extends Maintenance {
$this->output( "Finished $table... $this->updated of $this->processed rows updated\n" );
}
$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] ) );
}
protected function hexChar( $matches ) {
return sprintf( "\\x%02x", ord( $matches[1] ) );
}