From: Umherirrender Date: Sat, 20 Jan 2018 20:07:17 +0000 (+0100) Subject: Bypass wfGetDB when LoadBalancer is used in scope X-Git-Tag: 1.31.0-rc.0~851^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=4a790fdd3c0cd26c9d3e2577b6ea28cf1c6d9afc;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 788ae61bac..d403ab5810 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -434,8 +434,9 @@ class WikiPage implements Page, IDBAccessObject { 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 @@ class WikiPage implements Page, IDBAccessObject { ) { $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 @@ class WikiPage implements Page, IDBAccessObject { $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 @@ class WikiPage implements Page, IDBAccessObject { && $lb->getServerCount() > 1 && $lb->hasOrMadeRecentMasterChanges() ) { - $dbw = wfGetDB( DB_MASTER ); + $dbw = $lb->getConnection( DB_MASTER ); $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); } if ( $rev ) {