Merge "Use our fork of less.php" into REL1_31
[lhc/web/wiklou.git] / maintenance / lag.php
index 3df1169..f041e15 100644 (file)
@@ -21,7 +21,7 @@
  * @ingroup Maintenance
  */
 
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
 
 /**
  * Maintenance script to show database lag.
@@ -31,7 +31,7 @@ require_once( __DIR__ . '/Maintenance.php' );
 class DatabaseLag extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Shows database lag";
+               $this->addDescription( 'Shows database lag' );
                $this->addOption( 'r', "Don't exit immediately, but show the lag every 5 seconds" );
        }
 
@@ -39,14 +39,15 @@ class DatabaseLag extends Maintenance {
                if ( $this->hasOption( 'r' ) ) {
                        $lb = wfGetLB();
                        echo 'time     ';
-                       for ( $i = 1; $i < $lb->getServerCount(); $i++ ) {
+
+                       $serverCount = $lb->getServerCount();
+                       for ( $i = 1; $i < $serverCount; $i++ ) {
                                $hostname = $lb->getServerName( $i );
                                printf( "%-12s ", $hostname );
                        }
                        echo "\n";
 
                        while ( 1 ) {
-                               $lb->clearLagTimeCache();
                                $lags = $lb->getLagTimes();
                                unset( $lags[0] );
                                echo gmdate( 'H:i:s' ) . ' ';
@@ -67,5 +68,5 @@ class DatabaseLag extends Maintenance {
        }
 }
 
-$maintClass = "DatabaseLag";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+$maintClass = DatabaseLag::class;
+require_once RUN_MAINTENANCE_IF_MAIN;