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

Change subject: Replace deprecated wfGetLB() calls here and there
......................................................................


Replace deprecated wfGetLB() calls here and there

Change-Id: Ic7cec2dcc6b8e0d500a4c37eb134976b314c33ca
---
M includes/api/ApiMain.php
M includes/api/ApiQuerySiteinfo.php
M includes/auth/AuthManager.php
M includes/installer/MysqlUpdater.php
M includes/page/WikiPage.php
M includes/skins/Skin.php
M includes/specials/SpecialContributions.php
M includes/specials/SpecialDeletedContributions.php
M includes/specials/SpecialWatchlist.php
M includes/user/User.php
10 files changed, 25 insertions(+), 14 deletions(-)

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



diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 3bda3e8..82753a1 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1452,7 +1452,7 @@
 
                if ( $module->isWriteMode()
                        && $this->getUser()->isBot()
-                       && wfGetLB()->getServerCount() > 1
+                       && 
MediaWikiServices::getInstance()->getDBLoadBalancer()->getServerCount() > 1
                ) {
                        $this->checkBotReadOnly();
                }
@@ -1466,7 +1466,7 @@
                $numLagged = 0;
                $lagLimit = $this->getConfig()->get( 'APIMaxLagThreshold' );
                $laggedServers = [];
-               $loadBalancer = wfGetLB();
+               $loadBalancer = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
                foreach ( $loadBalancer->getLagTimes() as $serverIndex => $lag 
) {
                        if ( $lag > $lagLimit ) {
                                ++$numLagged;
@@ -1475,7 +1475,7 @@
                }
 
                // If a majority of replica DBs are too lagged then disallow 
writes
-               $replicaCount = wfGetLB()->getServerCount() - 1;
+               $replicaCount = $loadBalancer->getServerCount() - 1;
                if ( $numLagged >= ceil( $replicaCount / 2 ) ) {
                        $laggedServers = implode( ', ', $laggedServers );
                        wfDebugLog(
diff --git a/includes/api/ApiQuerySiteinfo.php 
b/includes/api/ApiQuerySiteinfo.php
index 2e9e69c..6bab826 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -449,7 +449,7 @@
 
        protected function appendDbReplLagInfo( $property, $includeAll ) {
                $data = [];
-               $lb = wfGetLB();
+               $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
                $showHostnames = $this->getConfig()->get( 'ShowHostnames' );
                if ( $includeAll ) {
                        if ( !$showHostnames ) {
diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php
index 9407c42..af070c2 100644
--- a/includes/auth/AuthManager.php
+++ b/includes/auth/AuthManager.php
@@ -1551,7 +1551,10 @@
                // Fetch the user ID from the master, so that we don't try to 
create the user
                // when they already exist, due to replication lag
                // @codeCoverageIgnoreStart
-               if ( !$localId && wfGetLB()->getReaderIndex() != 0 ) {
+               if (
+                       !$localId &&
+                       
MediaWikiServices::getInstance()->getDBLoadBalancer()->getReaderIndex() != 0
+               ) {
                        $localId = User::idFromName( $username, 
User::READ_LATEST );
                        $flags = User::READ_LATEST;
                }
diff --git a/includes/installer/MysqlUpdater.php 
b/includes/installer/MysqlUpdater.php
index a3caa07..44086a1 100644
--- a/includes/installer/MysqlUpdater.php
+++ b/includes/installer/MysqlUpdater.php
@@ -872,7 +872,8 @@
                $this->applyPatch( 'patch-templatelinks.sql', false, "Creating 
templatelinks table" );
 
                $this->output( "Populating...\n" );
-               if ( wfGetLB()->getServerCount() > 1 ) {
+               $services = MediaWikiServices::getInstance();
+               if ( $services->getDBLoadBalancer()->getServerCount() > 1 ) {
                        // Slow, replication-friendly update
                        $res = $this->db->select( 'pagelinks', [ 'pl_from', 
'pl_namespace', 'pl_title' ],
                                [ 'pl_namespace' => NS_TEMPLATE ], __METHOD__ );
@@ -880,7 +881,7 @@
                        foreach ( $res as $row ) {
                                $count = ( $count + 1 ) % 100;
                                if ( $count == 0 ) {
-                                       $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                                       $lbFactory = 
$services->getDBLoadBalancerFactory();
                                        $lbFactory->waitForReplication( [ 
'wiki' => wfWikiID() ] );
                                }
                                $this->db->insert( 'templatelinks',
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 6847671..788ae61 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -1425,14 +1425,15 @@
        ) {
                $baseRevId = null;
                if ( $edittime && $sectionId !== 'new' ) {
+                       $lb = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
                        $dbr = wfGetDB( 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
                        // to encourage loading of revisions by timestamp.
                        if ( !$rev
-                               && wfGetLB()->getServerCount() > 1
-                               && wfGetLB()->hasOrMadeRecentMasterChanges()
+                               && $lb->getServerCount() > 1
+                               && $lb->hasOrMadeRecentMasterChanges()
                        ) {
                                $dbw = wfGetDB( DB_MASTER );
                                $rev = Revision::loadFromTimestamp( $dbw, 
$this->mTitle, $edittime );
diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php
index 07964a4..c95f1f5 100644
--- a/includes/skins/Skin.php
+++ b/includes/skins/Skin.php
@@ -911,7 +911,7 @@
                        $s = '';
                }
 
-               if ( wfGetLB()->getLaggedReplicaMode() ) {
+               if ( 
MediaWikiServices::getInstance()->getDBLoadBalancer()->getLaggedReplicaMode() ) 
{
                        $s .= ' <strong>' . $this->msg( 'laggedslavemode' 
)->parse() . '</strong>';
                }
 
diff --git a/includes/specials/SpecialContributions.php 
b/includes/specials/SpecialContributions.php
index 5a5f005..4775a7f 100644
--- a/includes/specials/SpecialContributions.php
+++ b/includes/specials/SpecialContributions.php
@@ -21,6 +21,7 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
 use MediaWiki\Widget\DateInputWidget;
 
 /**
@@ -220,7 +221,8 @@
                                $out->addWikiMsg( 'nocontribs', $target );
                        } else {
                                # Show a message about replica DB lag, if 
applicable
-                               $lag = wfGetLB()->safeGetLag( 
$pager->getDatabase() );
+                               $lb = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
+                               $lag = $lb->safeGetLag( $pager->getDatabase() );
                                if ( $lag > 0 ) {
                                        $out->showLagWarning( $lag );
                                }
diff --git a/includes/specials/SpecialDeletedContributions.php 
b/includes/specials/SpecialDeletedContributions.php
index 5c8b3a6..975d64e 100644
--- a/includes/specials/SpecialDeletedContributions.php
+++ b/includes/specials/SpecialDeletedContributions.php
@@ -21,6 +21,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Implements Special:DeletedContributions to display archived revisions
  * @ingroup SpecialPage
@@ -97,7 +99,8 @@
                }
 
                # Show a message about replica DB lag, if applicable
-               $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
+               $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
+               $lag = $lb->safeGetLag( $pager->getDatabase() );
                if ( $lag > 0 ) {
                        $out->showLagWarning( $lag );
                }
diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index 2ad70a6..7b3f25c 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -486,7 +486,7 @@
                $output = $this->getOutput();
 
                # Show a message about replica DB lag, if applicable
-               $lag = wfGetLB()->safeGetLag( $dbr );
+               $lag = 
MediaWikiServices::getInstance()->getDBLoadBalancer()->safeGetLag( $dbr );
                if ( $lag > 0 ) {
                        $output->showLagWarning( $lag );
                }
diff --git a/includes/user/User.php b/includes/user/User.php
index 709bac7..0b3f8fd 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -384,7 +384,8 @@
                                break;
                        case 'name':
                                // Make sure this thread sees its own changes
-                               if ( wfGetLB()->hasOrMadeRecentMasterChanges() 
) {
+                               $lb = 
MediaWikiServices::getInstance()->getDBLoadBalancer();
+                               if ( $lb->hasOrMadeRecentMasterChanges() ) {
                                        $flags |= self::READ_LATEST;
                                        $this->queryFlagsUsed = $flags;
                                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7cec2dcc6b8e0d500a4c37eb134976b314c33ca
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: WMDE-Fisch <christoph.jau...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to