From 161f21ab5aa174b2c008399e7c5b73506ac8fd37 Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 9 Oct 2016 21:21:33 +0100 Subject: [PATCH] Database and LoadBalancer documentation updates Replace deprecated function calls Change-Id: Id7e4136d7258abb61117fff73d51766954605737 --- includes/EchoDbFactory.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/includes/EchoDbFactory.php b/includes/EchoDbFactory.php index 2ec9de13a..7cf6ed70b 100644 --- a/includes/EchoDbFactory.php +++ b/includes/EchoDbFactory.php @@ -1,4 +1,5 @@ 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'] );