diff options
Diffstat (limited to 'maintenance/purgeParserCache.php')
-rw-r--r-- | maintenance/purgeParserCache.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/maintenance/purgeParserCache.php b/maintenance/purgeParserCache.php index 4b550b6e..4d775f95 100644 --- a/maintenance/purgeParserCache.php +++ b/maintenance/purgeParserCache.php @@ -1,8 +1,14 @@ <?php +/** + * @ingroup Maintenance + * @file + */ require( dirname( __FILE__ ) . '/Maintenance.php' ); class PurgeParserCache extends Maintenance { + var $lastProgress; + function __construct() { parent::__construct(); $this->addDescription( "Remove old objects from the parser cache. " . @@ -31,12 +37,26 @@ class PurgeParserCache extends Maintenance { echo "Deleting objects expiring before " . $english->timeanddate( $date ) . "\n"; $pc = wfGetParserCacheStorage(); - $success = $pc->deleteObjectsExpiringBefore( $date ); + $success = $pc->deleteObjectsExpiringBefore( $date, array( $this, 'showProgress' ) ); if ( !$success ) { - echo "Cannot purge this kind of parser cache.\n"; + echo "\nCannot purge this kind of parser cache.\n"; exit( 1 ); } - echo "Done\n"; + $this->showProgress( 100 ); + echo "\nDone\n"; + } + + function showProgress( $percent ) { + $percentString = sprintf( "%.2f", $percent ); + if ( $percentString === $this->lastProgress ) { + return; + } + $this->lastProgress = $percentString; + + $stars = floor( $percent / 2 ); + echo '[' . str_repeat( '*', $stars ), str_repeat( '.', 50 - $stars ) . '] ' . + "$percentString%\r"; + } } $maintClass = 'PurgeParserCache'; |