/**
* @param array $conf An associative array with one member:
- * - connection: The DatabaseBase connection object
+ * - connection: The IDatabase connection object
*/
public function __construct( array $conf ) {
parent::__construct( $conf );
- $this->lb = new LoadBalancerSingle( array(
- 'readOnlyReason' => $this->readOnlyReason,
- 'trxProfiler' => $this->trxProfiler
- ) + $conf );
+ $this->lb = new LoadBalancerSingle( array_merge( $this->baseLoadBalancerParams(), $conf ) );
}
/**
* @param bool|string $wiki Wiki ID, or false for the current wiki
* @return LoadBalancerSingle
*/
- public function &getExternalLB( $cluster, $wiki = false ) {
+ public function getExternalLB( $cluster, $wiki = false ) {
return $this->lb;
}
* @param string|callable $callback
* @param array $params
*/
- public function forEachLB( $callback, array $params = array() ) {
- call_user_func_array( $callback, array_merge( array( $this->lb ), $params ) );
+ public function forEachLB( $callback, array $params = [] ) {
+ call_user_func_array( $callback, array_merge( [ $this->lb ], $params ) );
}
}
* Helper class for LBFactorySingle.
*/
class LoadBalancerSingle extends LoadBalancer {
- /** @var DatabaseBase */
+ /** @var IDatabase */
private $db;
/**
public function __construct( array $params ) {
$this->db = $params['connection'];
- parent::__construct( array(
- 'servers' => array(
- array(
+ parent::__construct( [
+ 'servers' => [
+ [
'type' => $this->db->getType(),
'host' => $this->db->getServer(),
'dbname' => $this->db->getDBname(),
'load' => 1,
- )
- ),
- 'trxProfiler' => $this->trxProfiler
- ) );
+ ]
+ ],
+ 'trxProfiler' => isset( $params['trxProfiler'] ) ? $params['trxProfiler'] : null,
+ 'srvCache' => isset( $params['srvCache'] ) ? $params['srvCache'] : null,
+ 'wanCache' => isset( $params['wanCache'] ) ? $params['wanCache'] : null
+ ] );
if ( isset( $params['readOnlyReason'] ) ) {
$this->db->setLBInfo( 'readOnlyReason', $params['readOnlyReason'] );
* @param string $server
* @param bool $dbNameOverride
*
- * @return DatabaseBase
+ * @return IDatabase
*/
protected function reallyOpenConnection( $server, $dbNameOverride = false ) {
return $this->db;