More silly ternary true : false fixes
[lhc/web/wiklou.git] / includes / db / LoadBalancer.php
index efd3749..1b3e204 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:
@@ -69,6 +69,8 @@ class LoadBalancer {
 
        /**
         * Get a LoadMonitor instance
+        *
+        * @return LoadMonitor
         */
        function getLoadMonitor() {
                if ( !isset( $this->mLoadMonitor ) ) {
@@ -89,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;
                }
@@ -220,7 +221,7 @@ class LoadBalancer {
                                        $i = $this->getRandomNonLagged( $currentLoads, $wiki );
                                        if ( $i === false && count( $currentLoads ) != 0 )  {
                                                # All slaves lagged. Switch to read-only mode
-                                               $wgReadOnly = wfMsgNoDBForContent( 'readonly_lag' );
+                                               $wgReadOnly = wfMessage( 'readonly_lag' )->useDatabase( false )->plain();
                                                $i = $this->pickRandom( $currentLoads );
                                                $laggedSlaveMode = true;
                                        }
@@ -354,6 +355,8 @@ class LoadBalancer {
        /**
         * Get any open connection to a given server index, local or foreign
         * Returns false if there is no connection open
+        *
+        * @return DatabaseBase
         */
        function getAnyOpenConnection( $i ) {
                foreach ( $this->mConns as $conns ) {
@@ -467,6 +470,8 @@ class LoadBalancer {
         * Mark a foreign connection as being available for reuse under a different
         * DB name or prefix. This mechanism is reference-counted, and must be called
         * the same number of times as getConnection() to work.
+        *
+        * @param DatabaseBase $conn
         */
        public function reuseConnection( $conn ) {
                $serverIndex = $conn->getLBInfo('serverIndex');
@@ -733,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