Add missing visibility keywords to all LoadBalancer methods
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Thu, 20 Nov 2014 15:45:57 +0000 (16:45 +0100)
committerThiemo Mättig <thiemo.maettig@wikimedia.de>
Thu, 20 Nov 2014 20:02:14 +0000 (21:02 +0100)
Quite a few methods are unused, at least in my code base (which does
not cover all extensions). I made them public. All other decisions
are based on the usage of that method in my code base. If you think
a specific method should be public, please tell me.

Change-Id: Ie83a2921fe02a198bd75c5ff7a41bcd4f0b4980b

includes/db/LBFactory.php
includes/db/LBFactoryMulti.php
includes/db/LBFactorySingle.php
includes/db/LoadBalancer.php

index 2f93ce7..e049a5d 100644 (file)
@@ -27,7 +27,7 @@
  */
 abstract class LBFactory {
        /** @var LBFactory */
-       protected static $instance;
+       private static $instance;
 
        /**
         * Disables all access to the load balancer, will cause all database access
@@ -43,7 +43,7 @@ abstract class LBFactory {
         *
         * @return LBFactory
         */
-       static function &singleton() {
+       public static function &singleton() {
                global $wgLBFactoryConf;
 
                if ( is_null( self::$instance ) ) {
@@ -87,7 +87,7 @@ abstract class LBFactory {
        /**
         * Shut down, close connections and destroy the cached instance.
         */
-       static function destroyInstance() {
+       public static function destroyInstance() {
                if ( self::$instance ) {
                        self::$instance->shutdown();
                        self::$instance->forEachLBCallMethod( 'closeAll' );
@@ -100,7 +100,7 @@ abstract class LBFactory {
         *
         * @param LBFactory $instance
         */
-       static function setInstance( $instance ) {
+       public static function setInstance( $instance ) {
                self::destroyInstance();
                self::$instance = $instance;
        }
@@ -109,7 +109,7 @@ abstract class LBFactory {
         * Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
         * @param array $conf
         */
-       abstract function __construct( array $conf );
+       public abstract function __construct( array $conf );
 
        /**
         * Create a new load balancer object. The resulting object will be untracked,
@@ -118,7 +118,7 @@ abstract class LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancer
         */
-       abstract function newMainLB( $wiki = false );
+       public abstract function newMainLB( $wiki = false );
 
        /**
         * Get a cached (tracked) load balancer object.
@@ -126,7 +126,7 @@ abstract class LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancer
         */
-       abstract function getMainLB( $wiki = false );
+       public abstract function getMainLB( $wiki = false );
 
        /**
         * Create a new load balancer for external storage. The resulting object will be
@@ -137,7 +137,7 @@ abstract class LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancer
         */
-       abstract function newExternalLB( $cluster, $wiki = false );
+       protected abstract function newExternalLB( $cluster, $wiki = false );
 
        /**
         * Get a cached (tracked) load balancer for external storage
@@ -146,7 +146,7 @@ abstract class LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancer
         */
-       abstract function &getExternalLB( $cluster, $wiki = false );
+       public abstract function &getExternalLB( $cluster, $wiki = false );
 
        /**
         * Execute a function for each tracked load balancer
@@ -156,13 +156,13 @@ abstract class LBFactory {
         * @param callable $callback
         * @param array $params
         */
-       abstract function forEachLB( $callback, array $params = array() );
+       public abstract function forEachLB( $callback, array $params = array() );
 
        /**
         * Prepare all tracked load balancers for shutdown
         * STUB
         */
-       function shutdown() {
+       public function shutdown() {
        }
 
        /**
@@ -171,24 +171,16 @@ abstract class LBFactory {
         * @param string $methodName
         * @param array $args
         */
-       function forEachLBCallMethod( $methodName, array $args = array() ) {
-               $this->forEachLB( array( $this, 'callMethod' ), array( $methodName, $args ) );
-       }
-
-       /**
-        * Private helper for forEachLBCallMethod
-        * @param LoadBalancer $loadBalancer
-        * @param string $methodName
-        * @param array $args
-        */
-       function callMethod( $loadBalancer, $methodName, $args ) {
-               call_user_func_array( array( $loadBalancer, $methodName ), $args );
+       private function forEachLBCallMethod( $methodName, array $args = array() ) {
+               $this->forEachLB( function( LoadBalancer $loadBalancer, $methodName, array $args ) {
+                       call_user_func_array( array( $loadBalancer, $methodName ), $args );
+               }, array( $methodName, $args ) );
        }
 
        /**
         * Commit changes on all master connections
         */
-       function commitMasterChanges() {
+       public function commitMasterChanges() {
                $this->forEachLBCallMethod( 'commitMasterChanges' );
        }
 
@@ -196,7 +188,7 @@ abstract class LBFactory {
         * Rollback changes on all master connections
         * @since 1.23
         */
-       function rollbackMasterChanges() {
+       public function rollbackMasterChanges() {
                $this->forEachLBCallMethod( 'rollbackMasterChanges' );
        }
 
@@ -205,7 +197,7 @@ abstract class LBFactory {
         * @since 1.23
         * @return bool
         */
-       function hasMasterChanges() {
+       public function hasMasterChanges() {
                $ret = false;
                $this->forEachLB( function ( $lb ) use ( &$ret ) {
                        $ret = $ret || $lb->hasMasterChanges();
@@ -219,15 +211,15 @@ abstract class LBFactory {
  */
 class LBFactorySimple extends LBFactory {
        /** @var LoadBalancer */
-       protected $mainLB;
+       private $mainLB;
 
        /** @var LoadBalancer[] */
-       protected $extLBs = array();
+       private $extLBs = array();
 
        /** @var ChronologyProtector */
-       protected $chronProt;
+       private $chronProt;
 
-       function __construct( array $conf ) {
+       public function __construct( array $conf ) {
                $this->chronProt = new ChronologyProtector;
        }
 
@@ -235,7 +227,7 @@ class LBFactorySimple extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancer
         */
-       function newMainLB( $wiki = false ) {
+       public function newMainLB( $wiki = false ) {
                global $wgDBservers;
                if ( $wgDBservers ) {
                        $servers = $wgDBservers;
@@ -274,7 +266,7 @@ class LBFactorySimple extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancer
         */
-       function getMainLB( $wiki = false ) {
+       public function getMainLB( $wiki = false ) {
                if ( !isset( $this->mainLB ) ) {
                        $this->mainLB = $this->newMainLB( $wiki );
                        $this->mainLB->parentInfo( array( 'id' => 'main' ) );
@@ -290,7 +282,7 @@ class LBFactorySimple extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancer
         */
-       function newExternalLB( $cluster, $wiki = false ) {
+       protected function newExternalLB( $cluster, $wiki = false ) {
                global $wgExternalServers;
                if ( !isset( $wgExternalServers[$cluster] ) ) {
                        throw new MWException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
@@ -306,7 +298,7 @@ class LBFactorySimple extends LBFactory {
         * @param bool|string $wiki
         * @return array
         */
-       function &getExternalLB( $cluster, $wiki = false ) {
+       public function &getExternalLB( $cluster, $wiki = false ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
                        $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $wiki );
                        $this->extLBs[$cluster]->parentInfo( array( 'id' => "ext-$cluster" ) );
@@ -324,7 +316,7 @@ class LBFactorySimple extends LBFactory {
         * @param callable $callback
         * @param array $params
         */
-       function forEachLB( $callback, array $params = array() ) {
+       public function forEachLB( $callback, array $params = array() ) {
                if ( isset( $this->mainLB ) ) {
                        call_user_func_array( $callback, array_merge( array( $this->mainLB ), $params ) );
                }
@@ -333,7 +325,7 @@ class LBFactorySimple extends LBFactory {
                }
        }
 
-       function shutdown() {
+       public function shutdown() {
                if ( $this->mainLB ) {
                        $this->chronProt->shutdownLB( $this->mainLB );
                }
@@ -352,26 +344,26 @@ class LBFactorySimple extends LBFactory {
  * LBFactory::enableBackend() to return to normal behavior
  */
 class LBFactoryFake extends LBFactory {
-       function __construct( array $conf ) {
+       public function __construct( array $conf ) {
        }
 
-       function newMainLB( $wiki = false ) {
+       public function newMainLB( $wiki = false ) {
                throw new DBAccessError;
        }
 
-       function getMainLB( $wiki = false ) {
+       public function getMainLB( $wiki = false ) {
                throw new DBAccessError;
        }
 
-       function newExternalLB( $cluster, $wiki = false ) {
+       protected function newExternalLB( $cluster, $wiki = false ) {
                throw new DBAccessError;
        }
 
-       function &getExternalLB( $cluster, $wiki = false ) {
+       public function &getExternalLB( $cluster, $wiki = false ) {
                throw new DBAccessError;
        }
 
-       function forEachLB( $callback, array $params = array() ) {
+       public function forEachLB( $callback, array $params = array() ) {
        }
 }
 
@@ -379,7 +371,7 @@ class LBFactoryFake extends LBFactory {
  * Exception class for attempted DB access
  */
 class DBAccessError extends MWException {
-       function __construct() {
+       public function __construct() {
                parent::__construct( "Mediawiki tried to access the database via wfGetDB(). " .
                        "This is not allowed." );
        }
index 7100615..aa305ab 100644 (file)
@@ -77,82 +77,82 @@ class LBFactoryMulti extends LBFactory {
        // Required settings
 
        /** @var array A map of database names to section names */
-       protected $sectionsByDB;
+       private $sectionsByDB;
 
        /**
         * @var array A 2-d map. For each section, gives a map of server names to
         * load ratios
         */
-       protected $sectionLoads;
+       private $sectionLoads;
 
        /**
         * @var array A server info associative array as documented for
         * $wgDBservers. The host, hostName and load entries will be
         * overridden
         */
-       protected $serverTemplate;
+       private $serverTemplate;
 
        // Optional settings
 
        /** @var array A 3-d map giving server load ratios for each section and group */
-       protected $groupLoadsBySection = array();
+       private $groupLoadsBySection = array();
 
        /** @var array A 3-d map giving server load ratios by DB name */
-       protected $groupLoadsByDB = array();
+       private $groupLoadsByDB = array();
 
        /** @var array A map of hostname to IP address */
-       protected $hostsByName = array();
+       private $hostsByName = array();
 
        /** @var array A map of external storage cluster name to server load map */
-       protected $externalLoads = array();
+       private $externalLoads = array();
 
        /**
         * @var array A set of server info keys overriding serverTemplate for
         * external storage
         */
-       protected $externalTemplateOverrides;
+       private $externalTemplateOverrides;
 
        /**
         * @var array A 2-d map overriding serverTemplate and
         * externalTemplateOverrides on a server-by-server basis. Applies to both
         * core and external storage
         */
-       protected $templateOverridesByServer;
+       private $templateOverridesByServer;
 
        /** @var array A 2-d map overriding the server info by external storage cluster */
-       protected $templateOverridesByCluster;
+       private $templateOverridesByCluster;
 
        /** @var array An override array for all master servers */
-       protected $masterTemplateOverrides;
+       private $masterTemplateOverrides;
 
        /**
         * @var array|bool A map of section name to read-only message. Missing or
         * false for read/write
         */
-       protected $readOnlyBySection = array();
+       private $readOnlyBySection = array();
 
        // Other stuff
 
        /** @var array Load balancer factory configuration */
-       protected $conf;
+       private $conf;
 
        /** @var LoadBalancer[] */
-       protected $mainLBs = array();
+       private $mainLBs = array();
 
        /** @var LoadBalancer[] */
-       protected $extLBs = array();
+       private $extLBs = array();
 
        /** @var string */
-       protected $lastWiki;
+       private $lastWiki;
 
        /** @var string */
-       protected $lastSection;
+       private $lastSection;
 
        /**
         * @param array $conf
         * @throws MWException
         */
-       function __construct( array $conf ) {
+       public function __construct( array $conf ) {
                $this->chronProt = new ChronologyProtector;
                $this->conf = $conf;
                $required = array( 'sectionsByDB', 'sectionLoads', 'serverTemplate' );
@@ -186,7 +186,7 @@ class LBFactoryMulti extends LBFactory {
         * @param bool|string $wiki
         * @return string
         */
-       function getSectionForWiki( $wiki = false ) {
+       private function getSectionForWiki( $wiki = false ) {
                if ( $this->lastWiki === $wiki ) {
                        return $this->lastSection;
                }
@@ -206,7 +206,7 @@ class LBFactoryMulti extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancer
         */
-       function newMainLB( $wiki = false ) {
+       public function newMainLB( $wiki = false ) {
                list( $dbName, ) = $this->getDBNameAndPrefix( $wiki );
                $section = $this->getSectionForWiki( $wiki );
                $groupLoads = array();
@@ -229,7 +229,7 @@ class LBFactoryMulti extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancer
         */
-       function getMainLB( $wiki = false ) {
+       public function getMainLB( $wiki = false ) {
                $section = $this->getSectionForWiki( $wiki );
                if ( !isset( $this->mainLBs[$section] ) ) {
                        $lb = $this->newMainLB( $wiki, $section );
@@ -247,7 +247,7 @@ class LBFactoryMulti extends LBFactory {
         * @throws MWException
         * @return LoadBalancer
         */
-       function newExternalLB( $cluster, $wiki = false ) {
+       protected function newExternalLB( $cluster, $wiki = false ) {
                if ( !isset( $this->externalLoads[$cluster] ) ) {
                        throw new MWException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
                }
@@ -267,7 +267,7 @@ class LBFactoryMulti extends LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancer
         */
-       function &getExternalLB( $cluster, $wiki = false ) {
+       public function &getExternalLB( $cluster, $wiki = false ) {
                if ( !isset( $this->extLBs[$cluster] ) ) {
                        $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $wiki );
                        $this->extLBs[$cluster]->parentInfo( array( 'id' => "ext-$cluster" ) );
@@ -285,7 +285,7 @@ class LBFactoryMulti extends LBFactory {
         * @param array $groupLoads
         * @return LoadBalancer
         */
-       function newLoadBalancer( $template, $loads, $groupLoads ) {
+       private function newLoadBalancer( $template, $loads, $groupLoads ) {
                $servers = $this->makeServerArray( $template, $loads, $groupLoads );
                $lb = new LoadBalancer( array(
                        'servers' => $servers,
@@ -302,7 +302,7 @@ class LBFactoryMulti extends LBFactory {
         * @param array $groupLoads
         * @return array
         */
-       function makeServerArray( $template, $loads, $groupLoads ) {
+       private function makeServerArray( $template, $loads, $groupLoads ) {
                $servers = array();
                $master = true;
                $groupLoadsByServer = $this->reindexGroupLoads( $groupLoads );
@@ -344,7 +344,7 @@ class LBFactoryMulti extends LBFactory {
         * @param array $groupLoads
         * @return array
         */
-       function reindexGroupLoads( $groupLoads ) {
+       private function reindexGroupLoads( $groupLoads ) {
                $reindexed = array();
                foreach ( $groupLoads as $group => $loads ) {
                        foreach ( $loads as $server => $load ) {
@@ -360,7 +360,7 @@ class LBFactoryMulti extends LBFactory {
         * @param bool|string $wiki
         * @return array
         */
-       function getDBNameAndPrefix( $wiki = false ) {
+       private function getDBNameAndPrefix( $wiki = false ) {
                if ( $wiki === false ) {
                        global $wgDBname, $wgDBprefix;
 
@@ -377,7 +377,7 @@ class LBFactoryMulti extends LBFactory {
         * @param callable $callback
         * @param array $params
         */
-       function forEachLB( $callback, array $params = array() ) {
+       public function forEachLB( $callback, array $params = array() ) {
                foreach ( $this->mainLBs as $lb ) {
                        call_user_func_array( $callback, array_merge( array( $lb ), $params ) );
                }
@@ -386,7 +386,7 @@ class LBFactoryMulti extends LBFactory {
                }
        }
 
-       function shutdown() {
+       public function shutdown() {
                foreach ( $this->mainLBs as $lb ) {
                        $this->chronProt->shutdownLB( $lb );
                }
index 03b7fbe..a41dadf 100644 (file)
  */
 class LBFactorySingle extends LBFactory {
        /** @var LoadBalancerSingle */
-       protected $lb;
+       private $lb;
 
        /**
         * @param array $conf An associative array with one member:
         *  - connection: The DatabaseBase connection object
         */
-       function __construct( array $conf ) {
+       public function __construct( array $conf ) {
                $this->lb = new LoadBalancerSingle( $conf );
        }
 
@@ -40,7 +40,7 @@ class LBFactorySingle extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancerSingle
         */
-       function newMainLB( $wiki = false ) {
+       public function newMainLB( $wiki = false ) {
                return $this->lb;
        }
 
@@ -48,7 +48,7 @@ class LBFactorySingle extends LBFactory {
         * @param bool|string $wiki
         * @return LoadBalancerSingle
         */
-       function getMainLB( $wiki = false ) {
+       public function getMainLB( $wiki = false ) {
                return $this->lb;
        }
 
@@ -57,7 +57,7 @@ class LBFactorySingle extends LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancerSingle
         */
-       function newExternalLB( $cluster, $wiki = false ) {
+       protected function newExternalLB( $cluster, $wiki = false ) {
                return $this->lb;
        }
 
@@ -66,7 +66,7 @@ class LBFactorySingle extends LBFactory {
         * @param bool|string $wiki Wiki ID, or false for the current wiki
         * @return LoadBalancerSingle
         */
-       function &getExternalLB( $cluster, $wiki = false ) {
+       public function &getExternalLB( $cluster, $wiki = false ) {
                return $this->lb;
        }
 
@@ -74,7 +74,7 @@ class LBFactorySingle extends LBFactory {
         * @param string|callable $callback
         * @param array $params
         */
-       function forEachLB( $callback, array $params = array() ) {
+       public function forEachLB( $callback, array $params = array() ) {
                call_user_func_array( $callback, array_merge( array( $this->lb ), $params ) );
        }
 }
@@ -84,12 +84,12 @@ class LBFactorySingle extends LBFactory {
  */
 class LoadBalancerSingle extends LoadBalancer {
        /** @var DatabaseBase */
-       protected $db;
+       private $db;
 
        /**
         * @param array $params
         */
-       function __construct( array $params ) {
+       public function __construct( array $params ) {
                $this->db = $params['connection'];
                parent::__construct( array( 'servers' => array( array(
                        'type' => $this->db->getType(),
@@ -106,7 +106,7 @@ class LoadBalancerSingle extends LoadBalancer {
         *
         * @return DatabaseBase
         */
-       function reallyOpenConnection( $server, $dbNameOverride = false ) {
+       protected function reallyOpenConnection( $server, $dbNameOverride = false ) {
                return $this->db;
        }
 }
index 4e11af2..07645bd 100644 (file)
@@ -67,7 +67,7 @@ class LoadBalancer {
         *   loadMonitor       Name of a class used to fetch server lag and load.
         * @throws MWException
         */
-       function __construct( array $params ) {
+       public function __construct( array $params ) {
                if ( !isset( $params['servers'] ) ) {
                        throw new MWException( __CLASS__ . ': missing servers parameter' );
                }
@@ -117,7 +117,7 @@ class LoadBalancer {
         *
         * @return LoadMonitor
         */
-       function getLoadMonitor() {
+       private function getLoadMonitor() {
                if ( !isset( $this->mLoadMonitor ) ) {
                        $class = $this->mLoadMonitorClass;
                        $this->mLoadMonitor = new $class( $this );
@@ -131,7 +131,7 @@ class LoadBalancer {
         * @param mixed $x
         * @return mixed
         */
-       function parentInfo( $x = null ) {
+       public function parentInfo( $x = null ) {
                return wfSetVar( $this->mParentInfo, $x );
        }
 
@@ -144,7 +144,7 @@ class LoadBalancer {
         * @param array $weights
         * @return bool|int|string
         */
-       function pickRandom( array $weights ) {
+       public function pickRandom( array $weights ) {
                return ArrayUtils::pickRandom( $weights );
        }
 
@@ -153,7 +153,7 @@ class LoadBalancer {
         * @param bool|string $wiki Wiki to get non-lagged for
         * @return bool|int|string
         */
-       function getRandomNonLagged( array $loads, $wiki = false ) {
+       private function getRandomNonLagged( array $loads, $wiki = false ) {
                # Unset excessively lagged servers
                $lags = $this->getLagTimes( $wiki );
                foreach ( $lags as $i => $lag ) {
@@ -202,7 +202,7 @@ class LoadBalancer {
         * @throws MWException
         * @return bool|int|string
         */
-       function getReaderIndex( $group = false, $wiki = false ) {
+       public function getReaderIndex( $group = false, $wiki = false ) {
                global $wgReadOnly, $wgDBtype;
 
                # @todo FIXME: For now, only go through all this for mysql databases
@@ -364,7 +364,7 @@ class LoadBalancer {
         * @param int $i
         * @return DatabaseBase|bool False on failure
         */
-       function getAnyOpenConnection( $i ) {
+       public function getAnyOpenConnection( $i ) {
                foreach ( $this->mConns as $conns ) {
                        if ( !empty( $conns[$i] ) ) {
                                return reset( $conns[$i] );
@@ -594,7 +594,7 @@ class LoadBalancer {
         *
         * @access private
         */
-       function openConnection( $i, $wiki = false ) {
+       public function openConnection( $i, $wiki = false ) {
                wfProfileIn( __METHOD__ );
                if ( $wiki !== false ) {
                        $conn = $this->openForeignConnection( $i, $wiki );
@@ -640,7 +640,7 @@ class LoadBalancer {
         * @param string $wiki Wiki ID to open
         * @return DatabaseBase
         */
-       function openForeignConnection( $i, $wiki ) {
+       private function openForeignConnection( $i, $wiki ) {
                wfProfileIn( __METHOD__ );
                list( $dbName, $prefix ) = wfSplitWikiID( $wiki );
                if ( isset( $this->mConns['foreignUsed'][$i][$wiki] ) ) {
@@ -706,7 +706,7 @@ class LoadBalancer {
         * @access private
         * @return bool
         */
-       function isOpen( $index ) {
+       private function isOpen( $index ) {
                if ( !is_integer( $index ) ) {
                        return false;
                }
@@ -724,7 +724,7 @@ class LoadBalancer {
         * @throws MWException
         * @return DatabaseBase
         */
-       function reallyOpenConnection( $server, $dbNameOverride = false ) {
+       protected function reallyOpenConnection( $server, $dbNameOverride = false ) {
                if ( !is_array( $server ) ) {
                        throw new MWException( 'You must update your load-balancing configuration. ' .
                                'See DefaultSettings.php entry for $wgDBservers.' );
@@ -789,7 +789,7 @@ class LoadBalancer {
        /**
         * @return int
         */
-       function getWriterIndex() {
+       private function getWriterIndex() {
                return 0;
        }
 
@@ -799,7 +799,7 @@ class LoadBalancer {
         * @param string $i
         * @return bool
         */
-       function haveIndex( $i ) {
+       public function haveIndex( $i ) {
                return array_key_exists( $i, $this->mServers );
        }
 
@@ -809,7 +809,7 @@ class LoadBalancer {
         * @param string $i
         * @return bool
         */
-       function isNonZeroLoad( $i ) {
+       public function isNonZeroLoad( $i ) {
                return array_key_exists( $i, $this->mServers ) && $this->mLoads[$i] != 0;
        }
 
@@ -818,7 +818,7 @@ class LoadBalancer {
         *
         * @return int
         */
-       function getServerCount() {
+       public function getServerCount() {
                return count( $this->mServers );
        }
 
@@ -828,7 +828,7 @@ class LoadBalancer {
         * @param string $i
         * @return string
         */
-       function getServerName( $i ) {
+       public function getServerName( $i ) {
                if ( isset( $this->mServers[$i]['hostName'] ) ) {
                        return $this->mServers[$i]['hostName'];
                } elseif ( isset( $this->mServers[$i]['host'] ) ) {
@@ -843,7 +843,7 @@ class LoadBalancer {
         * @param int $i
         * @return array|bool
         */
-       function getServerInfo( $i ) {
+       public function getServerInfo( $i ) {
                if ( isset( $this->mServers[$i] ) ) {
                        return $this->mServers[$i];
                } else {
@@ -857,7 +857,7 @@ class LoadBalancer {
         * @param int $i
         * @param array $serverInfo
         */
-       function setServerInfo( $i, array $serverInfo ) {
+       public function setServerInfo( $i, array $serverInfo ) {
                $this->mServers[$i] = $serverInfo;
        }
 
@@ -865,7 +865,7 @@ class LoadBalancer {
         * Get the current master position for chronology control purposes
         * @return mixed
         */
-       function getMasterPos() {
+       public function getMasterPos() {
                # If this entire request was served from a slave without opening a connection to the
                # master (however unlikely that may be), then we can fetch the position from the slave.
                $masterConn = $this->getAnyOpenConnection( 0 );
@@ -891,7 +891,7 @@ class LoadBalancer {
        /**
         * Close all open connections
         */
-       function closeAll() {
+       public function closeAll() {
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
                                /** @var DatabaseBase $conn */
@@ -913,7 +913,7 @@ class LoadBalancer {
         * If you use $conn->close() directly, the load balancer won't update its state.
         * @param DatabaseBase $conn
         */
-       function closeConnection( $conn ) {
+       public function closeConnection( $conn ) {
                $done = false;
                foreach ( $this->mConns as $i1 => $conns2 ) {
                        foreach ( $conns2 as $i2 => $conns3 ) {
@@ -935,7 +935,7 @@ class LoadBalancer {
        /**
         * Commit transactions on all open connections
         */
-       function commitAll() {
+       public function commitAll() {
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
                                /** @var DatabaseBase[] $conns3 */
@@ -951,7 +951,7 @@ class LoadBalancer {
        /**
         *  Issue COMMIT only on master, only if queries were done on connection
         */
-       function commitMasterChanges() {
+       public function commitMasterChanges() {
                // Always 0, but who knows.. :)
                $masterIndex = $this->getWriterIndex();
                foreach ( $this->mConns as $conns2 ) {
@@ -971,7 +971,7 @@ class LoadBalancer {
         * Issue ROLLBACK only on master, only if queries were done on connection
         * @since 1.23
         */
-       function rollbackMasterChanges() {
+       public function rollbackMasterChanges() {
                // Always 0, but who knows.. :)
                $masterIndex = $this->getWriterIndex();
                foreach ( $this->mConns as $conns2 ) {
@@ -991,7 +991,7 @@ class LoadBalancer {
         * @return bool Whether a master connection is already open
         * @since 1.24
         */
-       function hasMasterConnection() {
+       public function hasMasterConnection() {
                return $this->isOpen( $this->getWriterIndex() );
        }
 
@@ -1001,7 +1001,7 @@ class LoadBalancer {
         * @since 1.23
         * @return bool
         */
-       function hasMasterChanges() {
+       public function hasMasterChanges() {
                // Always 0, but who knows.. :)
                $masterIndex = $this->getWriterIndex();
                foreach ( $this->mConns as $conns2 ) {
@@ -1022,14 +1022,14 @@ class LoadBalancer {
         * @param mixed $value
         * @return mixed
         */
-       function waitTimeout( $value = null ) {
+       public function waitTimeout( $value = null ) {
                return wfSetVar( $this->mWaitTimeout, $value );
        }
 
        /**
         * @return bool
         */
-       function getLaggedSlaveMode() {
+       public function getLaggedSlaveMode() {
                return $this->mLaggedSlaveMode;
        }
 
@@ -1038,7 +1038,7 @@ class LoadBalancer {
         * @param null|bool $mode
         * @return bool
         */
-       function allowLagged( $mode = null ) {
+       public function allowLagged( $mode = null ) {
                if ( $mode === null ) {
                        return $this->mAllowLagged;
                }
@@ -1050,7 +1050,7 @@ class LoadBalancer {
        /**
         * @return bool
         */
-       function pingAll() {
+       public function pingAll() {
                $success = true;
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
@@ -1071,7 +1071,7 @@ class LoadBalancer {
         * @param callable $callback
         * @param array $params
         */
-       function forEachOpenConnection( $callback, array $params = array() ) {
+       public function forEachOpenConnection( $callback, array $params = array() ) {
                foreach ( $this->mConns as $conns2 ) {
                        foreach ( $conns2 as $conns3 ) {
                                foreach ( $conns3 as $conn ) {
@@ -1092,7 +1092,7 @@ class LoadBalancer {
         * @param bool|string $wiki Wiki ID, or false for the default database
         * @return array ( host, max lag, index of max lagged host )
         */
-       function getMaxLag( $wiki = false ) {
+       public function getMaxLag( $wiki = false ) {
                $maxLag = -1;
                $host = '';
                $maxIndex = 0;
@@ -1121,7 +1121,7 @@ class LoadBalancer {
         * @param string|bool $wiki
         * @return int[] Map of (server index => seconds)
         */
-       function getLagTimes( $wiki = false ) {
+       public function getLagTimes( $wiki = false ) {
                if ( $this->getServerCount() <= 1 ) {
                        return array( 0 => 0 ); // no replication = no lag
                }
@@ -1152,7 +1152,7 @@ class LoadBalancer {
         * @param DatabaseBase $conn
         * @return int
         */
-       function safeGetLag( $conn ) {
+       public function safeGetLag( $conn ) {
                if ( $this->getServerCount() == 1 ) {
                        return 0;
                } else {
@@ -1163,7 +1163,7 @@ class LoadBalancer {
        /**
         * Clear the cache for slag lag delay times
         */
-       function clearLagTimeCache() {
+       public function clearLagTimeCache() {
                $this->mProcCache->clear( 'slave_lag' );
        }
 }
@@ -1177,13 +1177,13 @@ class LoadBalancer {
  */
 class DBConnRef implements IDatabase {
        /** @var LoadBalancer */
-       protected $lb;
+       private $lb;
 
        /** @var DatabaseBase|null */
-       protected $conn;
+       private $conn;
 
        /** @var array|null */
-       protected $params;
+       private $params;
 
        /**
         * @param LoadBalancer $lb
@@ -1207,7 +1207,7 @@ class DBConnRef implements IDatabase {
                return call_user_func_array( array( $this->conn, $name ), $arguments );
        }
 
-       function __destruct() {
+       public function __destruct() {
                if ( $this->conn !== null ) {
                        $this->lb->reuseConnection( $this->conn );
                }