Database and LoadBalancer documentation updates

Replace deprecated function calls

Change-Id: Id7e4136d7258abb61117fff73d51766954605737
This commit is contained in:
Reedy 2016-10-09 21:21:33 +01:00
parent 7441dcc3d2
commit 161f21ab5a

View file

@ -1,4 +1,5 @@
<?php
use MediaWiki\MediaWikiServices;
/**
* Database factory class, this will determine whether to use the main database
@ -47,9 +48,9 @@ class MWEchoDbFactory {
protected function getLB() {
// Use the external db defined for Echo
if ( $this->cluster ) {
$lb = wfGetLBFactory()->getExternalLB( $this->cluster );
$lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getExternalLB( $this->cluster );
} else {
$lb = wfGetLB();
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
}
return $lb;
@ -60,9 +61,9 @@ class MWEchoDbFactory {
*/
protected function getSharedLB() {
if ( $this->sharedCluster ) {
$lb = wfGetLBFactory()->getExternalLB( $this->sharedCluster );
$lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getExternalLB( $this->sharedCluster );
} else {
$lb = wfGetLB();
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
}
return $lb;
@ -72,7 +73,7 @@ class MWEchoDbFactory {
* Get the database connection for Echo
* @param $db int Index of the connection to get
* @param $groups mixed Query groups.
* @return DatabaseBase
* @return IDatabase
*/
public function getEchoDb( $db, $groups = array() ) {
return $this->getLB()->getConnection( $db, $groups );
@ -81,7 +82,7 @@ class MWEchoDbFactory {
/**
* @param $db int Index of the connection to get
* @param array $groups Query groups
* @return bool|DatabaseBase false if no shared db is configured
* @return bool|IDatabase false if no shared db is configured
*/
public function getSharedDb( $db, $groups = array() ) {
if ( !$this->shared ) {
@ -91,8 +92,6 @@ class MWEchoDbFactory {
return $this->getSharedLB()->getConnection( $db, $groups, $this->shared );
}
/**
* Wrapper function for wfGetDB, some extensions like MobileFrontend is
* using this to issue sql queries against Echo database directly. This
@ -103,7 +102,7 @@ class MWEchoDbFactory {
* @param $db int Index of the connection to get
* @param $groups mixed Query groups.
* @param $wiki string|bool The wiki ID, or false for the current wiki
* @return DatabaseBase
* @return IDatabase
*/
public static function getDB( $db, $groups = array(), $wiki = false ) {
global $wgEchoCluster;
@ -136,7 +135,7 @@ class MWEchoDbFactory {
'wikiDb' => false,
'echoDb' => false,
);
$lb = wfGetLB();
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
if ( $lb->getServerCount() > 1 ) {
$position['wikiDb'] = $lb->getMasterPos();
};
@ -160,7 +159,7 @@ class MWEchoDbFactory {
*/
public function waitFor( array $position ) {
if ( $position['wikiDb'] ) {
wfGetLB()->waitFor( $position['wikiDb'] );
MediaWikiServices::getInstance()->getDBLoadBalancer()->waitFor( $position['wikiDb'] );
}
if ( $position['echoDb'] ) {
$this->getLB()->waitFor( $position['echoDb'] );