From: Sam Reed Date: Fri, 3 Jun 2011 22:59:34 +0000 (+0000) Subject: * (bug 29267) always give the servername for meta=siteinfo&siprop=dbrepllag X-Git-Tag: 1.31.0-rc.0~29727 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=fe611d4dc63b3f173a782cda0eaf7c4f642b1f6e;p=lhc%2Fweb%2Fwiklou.git * (bug 29267) always give the servername for meta=siteinfo&siprop=dbrepllag --- diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 5b40da3cfd..ea976a7dab 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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 === diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index ed277b90a8..b25b83ce1c 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -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 ) ); } diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 5cc9c1b622..2283a1e27c 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -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 ); } /**