* Fixed complete breakage of "lag.php -r" due to spurious line-endings introduced...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 18 Mar 2010 05:23:46 +0000 (05:23 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 18 Mar 2010 05:23:46 +0000 (05:23 +0000)
* Fixed breakage due to lag time cache, based on a hack in the WMF working copy.
* Tested locally.

includes/db/LoadBalancer.php
maintenance/lag.php

index 04bcc2a..dcc5316 100644 (file)
@@ -918,4 +918,11 @@ class LoadBalancer {
                $this->mLagTimes = $this->getLoadMonitor()->getLagTimes( array_keys( $this->mServers ), $wiki );
                return $this->mLagTimes;
        }
+
+       /**
+        * Clear the cache for getLagTimes
+        */
+       function clearLagTimeCache() {
+               $this->mLagTimes = null;
+       }
 }
index d5c1985..47b4c47 100644 (file)
@@ -18,21 +18,22 @@ class DatabaseLag extends Maintenance {
        public function execute() {
                if ( $this->hasOption( 'r' ) ) {
                        $lb = wfGetLB();
-                       $this->output( 'time     ' );
-                       for( $i = 0; $i < $lb->getServerCount(); $i++ ) {
+                       echo 'time     ';
+                       for( $i = 1; $i < $lb->getServerCount(); $i++ ) {
                                $hostname = $lb->getServerName( $i );
-                               $this->output( sprintf( "%-12s ", $hostname ) );
+                               printf( "%-12s ", $hostname );
                        }
-                       $this->output( "\n" );
+                       echo "\n";
 
                        while( 1 ) {
+                               $lb->clearLagTimeCache();
                                $lags = $lb->getLagTimes();
                                unset( $lags[0] );
-                               $this->output( gmdate( 'H:i:s' ) . ' ' );
+                               echo gmdate( 'H:i:s' ) . ' ';
                                foreach( $lags as $i => $lag ) {
-                                       $this->output( sprintf( "%-12s " , $lag === false ? 'false' : $lag ) );
+                                       printf( "%-12s " , $lag === false ? 'false' : $lag );
                                }
-                               $this->output( "\n" );
+                               echo "\n";
                                sleep( 5 );
                        }
                } else {