[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Replace deprecated wfGetLB() calls here and there

2018-01-20 Thread jenkins-bot (Code Review)
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' => 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Replace deprecated wfGetLB() calls here and there

2018-01-04 Thread WMDE-Fisch (Code Review)
WMDE-Fisch has uploaded a new change for review. ( 
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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/76/402076/1

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 bc7725e..d7a8f1f 100644
--- a/includes/installer/MysqlUpdater.php
+++ b/includes/installer/MysqlUpdater.php
@@ -871,7 +871,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__ );
@@ -879,7 +880,7 @@
foreach ( $res as $row ) {
$count = ( $count + 1 ) % 100;
if ( $count == 0 ) {
-   $lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+   $lbFactory = 
$services->getDBLoadBalancerFactory();
$lbFactory->waitForReplication( [ 
'wiki' => wfWikiID()