* (bug 29267) always give the servername for meta=siteinfo&siprop=dbrepllag
authorSam Reed <reedy@users.mediawiki.org>
Fri, 3 Jun 2011 22:59:34 +0000 (22:59 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 3 Jun 2011 22:59:34 +0000 (22:59 +0000)
RELEASE-NOTES-1.19
includes/api/ApiQuerySiteinfo.php
includes/db/LoadBalancer.php

index 5b40da3..ea976a7 100644 (file)
@@ -94,6 +94,7 @@ production.
 * (bug 20699) API watchlist should list log-events
 * (bug 29070) Add token to action=watch
 * (bug 29221) Expose oldrevid in watchlist output
+* (bug 29267) always give the servername for meta=siteinfo&siprop=dbrepllag
 
 === Languages updated in 1.19 ===
 
index ed277b9..b25b83c 100644 (file)
@@ -298,12 +298,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        protected function appendDbReplLagInfo( $property, $includeAll ) {
                global $wgShowHostnames;
                $data = array();
+               $lb = wfGetLB();
                if ( $includeAll ) {
                        if ( !$wgShowHostnames ) {
                                $this->dieUsage( 'Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied' );
                        }
 
-                       $lb = wfGetLB();
                        $lags = $lb->getLagTimes();
                        foreach ( $lags as $i => $lag ) {
                                $data[] = array(
@@ -312,9 +312,11 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                );
                        }
                } else {
-                       list( $host, $lag ) = wfGetLB()->getMaxLag();
+                       list( $host, $lag, $index ) = $lb->getMaxLag();
                        $data[] = array(
-                               'host' => $wgShowHostnames ? $host : '',
+                               'host' => $wgShowHostnames
+                                               ? $lb->getServerName( $index )
+                                               : '',
                                'lag' => intval( $lag )
                        );
                }
index 5cc9c1b..2283a1e 100644 (file)
@@ -921,10 +921,13 @@ class LoadBalancer {
         * This is useful for maintenance scripts that need to throttle their updates.
         * May attempt to open connections to slaves on the default DB.
         * @param $wiki string Wiki ID, or false for the default database
+        *
+        * @return array ( host, max lag, index of max lagged host )
         */
        function getMaxLag( $wiki = false ) {
                $maxLag = -1;
                $host = '';
+               $maxIndex = 0;
                foreach ( $this->mServers as $i => $conn ) {
                        $conn = false;
                        if ( $wiki === false ) {
@@ -940,9 +943,10 @@ class LoadBalancer {
                        if ( $lag > $maxLag ) {
                                $maxLag = $lag;
                                $host = $this->mServers[$i]['host'];
+                               $maxIndex = $i;
                        }
                }
-               return array( $host, $maxLag );
+               return array( $host, $maxLag, $maxIndex );
        }
 
        /**