Merge "Slight improvements to FormSpecialPage behavior."
[lhc/web/wiklou.git] / includes / db / LoadBalancer.php
index 187870f..12e493a 100644 (file)
@@ -78,7 +78,7 @@ class LoadBalancer {
                        }
                }
 
-               foreach( $params['servers'] as $i => $server ) {
+               foreach ( $params['servers'] as $i => $server ) {
                        $this->mLoads[$i] = $server['load'];
                        if ( isset( $server['groupLoads'] ) ) {
                                foreach ( $server['groupLoads'] as $group => $ratio ) {
@@ -117,7 +117,7 @@ class LoadBalancer {
         * Given an array of non-normalised probabilities, this function will select
         * an element and return the appropriate key
         *
-        * @deprecated 1.21, use ArrayUtils::pickRandom()
+        * @deprecated since 1.21, use ArrayUtils::pickRandom()
         *
         * @param $weights array
         *
@@ -219,6 +219,7 @@ class LoadBalancer {
                }
 
                if ( !$nonErrorLoads ) {
+                       wfProfileOut( __METHOD__ );
                        throw new MWException( "Empty server array given to LoadBalancer" );
                }
 
@@ -348,7 +349,7 @@ class LoadBalancer {
         * Set the master wait position
         * If a DB_SLAVE connection has been opened already, waits
         * Otherwise sets a variable telling it to wait if such a connection is opened
-        * @param $pos int
+        * @param $pos DBMasterPos
         */
        public function waitFor( $pos ) {
                wfProfileIn( __METHOD__ );
@@ -366,7 +367,7 @@ class LoadBalancer {
 
        /**
         * Set the master wait position and wait for ALL slaves to catch up to it
-        * @param $pos int
+        * @param $pos DBMasterPos
         */
        public function waitForAll( $pos ) {
                wfProfileIn( __METHOD__ );
@@ -399,7 +400,7 @@ class LoadBalancer {
         * @param $open bool
         * @return bool
         */
-       function doWait( $index, $open = false ) {
+       protected function doWait( $index, $open = false ) {
                # Find a connection to wait on
                $conn = $this->getAnyOpenConnection( $index );
                if ( !$conn ) {
@@ -443,8 +444,10 @@ class LoadBalancer {
                wfProfileIn( __METHOD__ );
 
                if ( $i == DB_LAST ) {
+                       wfProfileOut( __METHOD__ );
                        throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' );
                } elseif ( $i === null || $i === false ) {
+                       wfProfileOut( __METHOD__ );
                        throw new MWException( 'Attempt to call ' . __METHOD__ . ' with invalid server index' );
                }
 
@@ -662,7 +665,7 @@ class LoadBalancer {
         * @return bool
         */
        function isOpen( $index ) {
-               if( !is_integer( $index ) ) {
+               if ( !is_integer( $index ) ) {
                        return false;
                }
                return (bool)$this->getAnyOpenConnection( $index );
@@ -679,7 +682,7 @@ class LoadBalancer {
         * @return DatabaseBase
         */
        function reallyOpenConnection( $server, $dbNameOverride = false ) {
-               if( !is_array( $server ) ) {
+               if ( !is_array( $server ) ) {
                        throw new MWException( 'You must update your load-balancing configuration. ' .
                                'See DefaultSettings.php entry for $wgDBservers.' );
                }
@@ -830,7 +833,7 @@ class LoadBalancer {
         */
        function closeAll() {
                foreach ( $this->mConns as $conns2 ) {
-                       foreach  ( $conns2 as $conns3 ) {
+                       foreach ( $conns2 as $conns3 ) {
                                foreach ( $conns3 as $conn ) {
                                        $conn->close();
                                }