Merge "Add the ability to know if fullscreen is available"
[lhc/web/wiklou.git] / includes / db / LoadBalancer.php
index 7d0fe34..e35c4c4 100644 (file)
@@ -144,10 +144,10 @@ class LoadBalancer {
                foreach ( $lags as $i => $lag ) {
                        if ( $i != 0 ) {
                                if ( $lag === false ) {
-                                       wfDebugLog( 'replication', "Server #$i is not replicating\n" );
+                                       wfDebugLog( 'replication', "Server #$i is not replicating" );
                                        unset( $loads[$i] );
                                } elseif ( isset( $this->mServers[$i]['max lag'] ) && $lag > $this->mServers[$i]['max lag'] ) {
-                                       wfDebugLog( 'replication', "Server #$i is excessively lagged ($lag seconds)\n" );
+                                       wfDebugLog( 'replication', "Server #$i is excessively lagged ($lag seconds)" );
                                        unset( $loads[$i] );
                                }
                        }
@@ -203,7 +203,7 @@ class LoadBalancer {
                        return $this->mReadIndex;
                }
 
-               wfProfileIn( __METHOD__ );
+               $section = new ProfileSection( __METHOD__ );
 
                # Find the relevant load array
                if ( $group !== false ) {
@@ -212,7 +212,6 @@ class LoadBalancer {
                        } else {
                                # No loads for this group, return false and the caller can use some other group
                                wfDebug( __METHOD__ . ": no loads for group $group\n" );
-                               wfProfileOut( __METHOD__ );
 
                                return false;
                        }
@@ -221,7 +220,6 @@ class LoadBalancer {
                }
 
                if ( !count( $nonErrorLoads ) ) {
-                       wfProfileOut( __METHOD__ );
                        throw new MWException( "Empty server array given to LoadBalancer" );
                }
 
@@ -242,7 +240,7 @@ class LoadBalancer {
                                $i = $this->getRandomNonLagged( $currentLoads, $wiki );
                                if ( $i === false && count( $currentLoads ) != 0 ) {
                                        # All slaves lagged. Switch to read-only mode
-                                       wfDebugLog( 'replication', "All slaves lagged. Switch to read-only mode\n" );
+                                       wfDebugLog( 'replication', "All slaves lagged. Switch to read-only mode" );
                                        $wgReadOnly = 'The database has been automatically locked ' .
                                                'while the slave database servers catch up to the master';
                                        $i = ArrayUtils::pickRandom( $currentLoads );
@@ -254,18 +252,17 @@ class LoadBalancer {
                                # pickRandom() returned false
                                # This is permanent and means the configuration or the load monitor
                                # wants us to return false.
-                               wfDebugLog( 'connect', __METHOD__ . ": pickRandom() returned false\n" );
-                               wfProfileOut( __METHOD__ );
+                               wfDebugLog( 'connect', __METHOD__ . ": pickRandom() returned false" );
 
                                return false;
                        }
 
                        wfDebugLog( 'connect', __METHOD__ .
-                               ": Using reader #$i: {$this->mServers[$i]['host']}...\n" );
+                               ": Using reader #$i: {$this->mServers[$i]['host']}..." );
 
                        $conn = $this->openConnection( $i, $wiki );
                        if ( !$conn ) {
-                               wfDebugLog( 'connect', __METHOD__ . ": Failed connecting to $i/$wiki\n" );
+                               wfDebugLog( 'connect', __METHOD__ . ": Failed connecting to $i/$wiki" );
                                unset( $nonErrorLoads[$i] );
                                unset( $currentLoads[$i] );
                                continue;
@@ -283,7 +280,7 @@ class LoadBalancer {
 
                # If all servers were down, quit now
                if ( !count( $nonErrorLoads ) ) {
-                       wfDebugLog( 'connect', "All servers down\n" );
+                       wfDebugLog( 'connect', "All servers down" );
                }
 
                if ( $i !== false ) {
@@ -294,11 +291,10 @@ class LoadBalancer {
                                        $this->mServers[$i]['slave pos'] = $conn->getSlavePos();
                                }
                        }
-                       if ( $this->mReadIndex <= 0 && $this->mLoads[$i] > 0 && $i !== false ) {
+                       if ( $this->mReadIndex <= 0 && $this->mLoads[$i] > 0 && $group !== false ) {
                                $this->mReadIndex = $i;
                        }
                }
-               wfProfileOut( __METHOD__ );
 
                return $i;
        }