jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405542 )

Change subject: Bypass wfGetDB when LoadBalancer is used in scope
......................................................................


Bypass wfGetDB when LoadBalancer is used in scope

wfGetDB calls LoadBalander::getConnection for $wiki=false,
when there is already a LoadBalancer in scope, call it directly

Change-Id: I4e29fd4e93a0d1f274e61af99c96021d3d06f8f3
---
M includes/page/WikiPage.php
1 file changed, 6 insertions(+), 4 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 788ae61..d403ab5 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -434,8 +434,9 @@
 
                if ( is_int( $from ) ) {
                        list( $index, $opts ) = 
DBAccessObjectUtils::getDBOptions( $from );
-                       $data = $this->pageDataFromTitle( wfGetDB( $index ), 
$this->mTitle, $opts );
                        $loadBalancer = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
+                       $db = $loadBalancer->getConnection( $index );
+                       $data = $this->pageDataFromTitle( $db, $this->mTitle, 
$opts );
 
                        if ( !$data
                                && $index == DB_REPLICA
@@ -444,7 +445,8 @@
                        ) {
                                $from = self::READ_LATEST;
                                list( $index, $opts ) = 
DBAccessObjectUtils::getDBOptions( $from );
-                               $data = $this->pageDataFromTitle( wfGetDB( 
$index ), $this->mTitle, $opts );
+                               $db = $loadBalancer->getConnection( $index );
+                               $data = $this->pageDataFromTitle( $db, 
$this->mTitle, $opts );
                        }
                } else {
                        // No idea from where the caller got this data, assume 
replica DB.
@@ -1426,7 +1428,7 @@
                $baseRevId = null;
                if ( $edittime && $sectionId !== 'new' ) {
                        $lb = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
-                       $dbr = wfGetDB( DB_REPLICA );
+                       $dbr = $lb->getConnection( DB_REPLICA );
                        $rev = Revision::loadFromTimestamp( $dbr, 
$this->mTitle, $edittime );
                        // Try the master if this thread may have just added it.
                        // This could be abstracted into a Revision method, but 
we don't want
@@ -1435,7 +1437,7 @@
                                && $lb->getServerCount() > 1
                                && $lb->hasOrMadeRecentMasterChanges()
                        ) {
-                               $dbw = wfGetDB( DB_MASTER );
+                               $dbw = $lb->getConnection( DB_MASTER );
                                $rev = Revision::loadFromTimestamp( $dbw, 
$this->mTitle, $edittime );
                        }
                        if ( $rev ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/405542
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4e29fd4e93a0d1f274e61af99c96021d3d06f8f3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: WMDE-Fisch <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to