Apply LoadBalancer related fixes
authorSam Reed <reedy@users.mediawiki.org>
Mon, 18 Apr 2011 23:12:58 +0000 (23:12 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 18 Apr 2011 23:12:58 +0000 (23:12 +0000)
Patches by Yuvi Panda

From (bug 28583) Remove all /* private */ declarations in MediaWiki core

CREDITS
includes/db/LoadBalancer.php
maintenance/eval.php

diff --git a/CREDITS b/CREDITS
index b9ef935..9c8c010 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -142,6 +142,7 @@ following names for their contribution to the product.
 * Tisane
 * Umherirrender
 * Ville Stadista
+* Yuvaraj Pandian T
 * Zachary Hauri
 
 == Translators ==
index 46c6155..42b4aa6 100644 (file)
  * @ingroup Database
  */
 class LoadBalancer {
-       /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads;
-       /* private */ var $mErrorConnection;
-       /* private */ var $mReadIndex, $mAllowLagged;
-       /* private */ var $mWaitForPos, $mWaitTimeout;
-       /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error';
-       /* private */ var $mParentInfo, $mLagTimes;
-       /* private */ var $mLoadMonitorClass, $mLoadMonitor;
+       private $mServers, $mConns, $mLoads, $mGroupLoads;
+       private $mErrorConnection;
+       private $mReadIndex, $mAllowLagged;
+       private $mWaitForPos, $mWaitTimeout;
+       private $mLaggedSlaveMode, $mLastError = 'Unknown error';
+       private $mParentInfo, $mLagTimes;
+       private $mLoadMonitorClass, $mLoadMonitor;
 
        /**
         * @param $params Array with keys:
@@ -91,8 +91,7 @@ class LoadBalancer {
         * Given an array of non-normalised probabilities, this function will select
         * an element and return the appropriate key
         */
-       function pickRandom( $weights )
-       {
+       function pickRandom( $weights ) {
                if ( !is_array( $weights ) || count( $weights ) == 0 ) {
                        return false;
                }
@@ -739,6 +738,13 @@ class LoadBalancer {
                }
        }
 
+       /**
+        * Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist
+        */
+       function setServerInfo( $i, $serverInfo ) {
+               $this->mServers[i] = $serverInfo;
+       }
+
        /**
         * Get the current master position for chronology control purposes
         * @return mixed
index 74143b5..33c9a5d 100644 (file)
@@ -45,8 +45,11 @@ if ( isset( $options['d'] ) ) {
        }
        if ( $d > 1 ) {
                $lb = wfGetLB();
-               foreach ( $lb->mServers as $i => $server ) {
-                       $lb->mServers[$i]['flags'] |= DBO_DEBUG;
+               $serverCount = $lb->getServerCount(); 
+               for ( $i = 0; $i < $serverCount; $i++ ) {
+                       $server = $lb->getServerInfo( $i );
+                       $server['flags'] |= DBO_DEBUG;
+                       $lb->setServerInfo( $i, $server );
                }
        }
        if ( $d > 2 ) {