Replace wfGetLBFactory
@deprecated since 1.27 Change-Id: I11a7253cebe525948a55cebee183e6de128fdc39
This commit is contained in:
parent
60d44a6a58
commit
554f9c857c
12 changed files with 56 additions and 31 deletions
|
|
@ -3052,7 +3052,8 @@ function wfWaitForSlaves(
|
|||
}
|
||||
|
||||
try {
|
||||
wfGetLBFactory()->waitForReplication( [
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lbFactory->waitForReplication( [
|
||||
'wiki' => $wiki,
|
||||
'cluster' => $cluster,
|
||||
'timeout' => $timeout,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\LoadBalancer;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\DBConnRef;
|
||||
|
|
@ -114,7 +115,8 @@ class ExternalStoreDB extends ExternalStoreMedium {
|
|||
* @return LoadBalancer
|
||||
*/
|
||||
private function getLoadBalancer( $cluster ) {
|
||||
return wfGetLBFactory()->getExternalLB( $cluster );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
return $lbFactory->getExternalLB( $cluster );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Session\BotPasswordSessionProvider;
|
||||
use Wikimedia\Rdbms\IMaintainableDatabase;
|
||||
|
||||
|
|
@ -74,9 +75,10 @@ class BotPassword implements IDBAccessObject {
|
|||
public static function getDB( $db ) {
|
||||
global $wgBotPasswordsCluster, $wgBotPasswordsDatabase;
|
||||
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lb = $wgBotPasswordsCluster
|
||||
? wfGetLBFactory()->getExternalLB( $wgBotPasswordsCluster )
|
||||
: wfGetLB( $wgBotPasswordsDatabase );
|
||||
? $lbFactory->getExternalLB( $wgBotPasswordsCluster )
|
||||
: $lbFactory->getMainLB( $wgBotPasswordsDatabase );
|
||||
return $lb->getConnectionRef( $db, [], $wgBotPasswordsDatabase );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\LoadBalancer;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
|
|
@ -323,7 +324,8 @@ class BackupDumper extends Maintenance {
|
|||
return $this->forcedDb;
|
||||
}
|
||||
|
||||
$this->lb = wfGetLBFactory()->newMainLB();
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$this->lb = $lbFactory->newMainLB();
|
||||
$db = $this->lb->getConnection( DB_REPLICA, 'dump' );
|
||||
|
||||
// Discourage the server from disconnecting us if it takes a long time
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ require_once __DIR__ . '/backup.inc';
|
|||
require_once __DIR__ . '/7zip.inc';
|
||||
require_once __DIR__ . '/../includes/export/WikiExporter.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IMaintainableDatabase;
|
||||
|
||||
/**
|
||||
|
|
@ -218,7 +219,8 @@ TEXT
|
|||
// individually retrying at different layers of code.
|
||||
|
||||
try {
|
||||
$this->lb = wfGetLBFactory()->newMainLB();
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$this->lb = $lbFactory->newMainLB();
|
||||
} catch ( Exception $e ) {
|
||||
throw new MWException( __METHOD__
|
||||
. " rotating DB failed to obtain new load balancer (" . $e->getMessage() . ")" );
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@
|
|||
*/
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\ILBFactory;
|
||||
|
||||
/**
|
||||
* Maintenance script that rebuilds recent changes from scratch.
|
||||
|
|
@ -64,11 +66,12 @@ class RebuildRecentchanges extends Maintenance {
|
|||
$this->fatalError( "Both 'from' and 'to' must be given, or neither" );
|
||||
}
|
||||
|
||||
$this->rebuildRecentChangesTablePass1();
|
||||
$this->rebuildRecentChangesTablePass2();
|
||||
$this->rebuildRecentChangesTablePass3();
|
||||
$this->rebuildRecentChangesTablePass4();
|
||||
$this->rebuildRecentChangesTablePass5();
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$this->rebuildRecentChangesTablePass1( $lbFactory );
|
||||
$this->rebuildRecentChangesTablePass2( $lbFactory );
|
||||
$this->rebuildRecentChangesTablePass3( $lbFactory );
|
||||
$this->rebuildRecentChangesTablePass4( $lbFactory );
|
||||
$this->rebuildRecentChangesTablePass5( $lbFactory );
|
||||
if ( !( $this->hasOption( 'from' ) && $this->hasOption( 'to' ) ) ) {
|
||||
$this->purgeFeeds();
|
||||
}
|
||||
|
|
@ -78,7 +81,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
/**
|
||||
* Rebuild pass 1: Insert `recentchanges` entries for page revisions.
|
||||
*/
|
||||
private function rebuildRecentChangesTablePass1() {
|
||||
private function rebuildRecentChangesTablePass1( ILBFactory $lbFactory ) {
|
||||
$dbw = $this->getDB( DB_MASTER );
|
||||
$commentStore = CommentStore::getStore();
|
||||
|
||||
|
|
@ -110,7 +113,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
);
|
||||
foreach ( array_chunk( $rcids, $this->getBatchSize() ) as $rcidBatch ) {
|
||||
$dbw->delete( 'recentchanges', [ 'rc_id' => $rcidBatch ], __METHOD__ );
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
|
||||
$this->output( "Loading from page and revision tables...\n" );
|
||||
|
|
@ -166,7 +169,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
__METHOD__
|
||||
);
|
||||
if ( ( ++$inserted % $this->getBatchSize() ) == 0 ) {
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -175,7 +178,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
* Rebuild pass 2: Enhance entries for page revisions with references to the previous revision
|
||||
* (rc_last_oldid, rc_new etc.) and size differences (rc_old_len, rc_new_len).
|
||||
*/
|
||||
private function rebuildRecentChangesTablePass2() {
|
||||
private function rebuildRecentChangesTablePass2( ILBFactory $lbFactory ) {
|
||||
$dbw = $this->getDB( DB_MASTER );
|
||||
|
||||
$this->output( "Updating links and size differences...\n" );
|
||||
|
|
@ -256,7 +259,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
$lastSize = $size;
|
||||
|
||||
if ( ( ++$updated % $this->getBatchSize() ) == 0 ) {
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -265,7 +268,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
/**
|
||||
* Rebuild pass 3: Insert `recentchanges` entries for action logs.
|
||||
*/
|
||||
private function rebuildRecentChangesTablePass3() {
|
||||
private function rebuildRecentChangesTablePass3( ILBFactory $lbFactory ) {
|
||||
global $wgLogTypes, $wgLogRestrictions;
|
||||
|
||||
$dbw = $this->getDB( DB_MASTER );
|
||||
|
|
@ -338,7 +341,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
);
|
||||
|
||||
if ( ( ++$inserted % $this->getBatchSize() ) == 0 ) {
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -346,7 +349,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
/**
|
||||
* Rebuild pass 4: Mark bot and autopatrolled entries.
|
||||
*/
|
||||
private function rebuildRecentChangesTablePass4() {
|
||||
private function rebuildRecentChangesTablePass4( ILBFactory $lbFactory ) {
|
||||
global $wgUseRCPatrol, $wgMiserMode;
|
||||
|
||||
$dbw = $this->getDB( DB_MASTER );
|
||||
|
|
@ -405,7 +408,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
[ 'rc_id' => $rcidBatch ],
|
||||
__METHOD__
|
||||
);
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -444,7 +447,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
],
|
||||
__METHOD__
|
||||
);
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -454,7 +457,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
* Rebuild pass 5: Delete duplicate entries where we generate both a page revision and a log entry
|
||||
* for a single action (upload only, at the moment, but potentially also move, protect, ...).
|
||||
*/
|
||||
private function rebuildRecentChangesTablePass5() {
|
||||
private function rebuildRecentChangesTablePass5( ILBFactory $lbFactory ) {
|
||||
$dbw = wfGetDB( DB_MASTER );
|
||||
|
||||
$this->output( "Removing duplicate revision and logging entries...\n" );
|
||||
|
|
@ -493,7 +496,7 @@ class RebuildRecentchanges extends Maintenance {
|
|||
);
|
||||
|
||||
if ( ( ++$updates % $this->getBatchSize() ) == 0 ) {
|
||||
wfGetLBFactory()->waitForReplication();
|
||||
$lbFactory->waitForReplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\ResultWrapper;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\DBQueryError;
|
||||
|
|
@ -54,10 +55,11 @@ class MwSql extends Maintenance {
|
|||
// We wan't to allow "" for the wikidb, meaning don't call select_db()
|
||||
$wiki = $this->hasOption( 'wikidb' ) ? $this->getOption( 'wikidb' ) : false;
|
||||
// Get the appropriate load balancer (for this wiki)
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
if ( $this->hasOption( 'cluster' ) ) {
|
||||
$lb = wfGetLBFactory()->getExternalLB( $this->getOption( 'cluster' ) );
|
||||
$lb = $lbFactory->getExternalLB( $this->getOption( 'cluster' ) );
|
||||
} else {
|
||||
$lb = wfGetLB( $wiki );
|
||||
$lb = $lbFactory->getMainLB( $wiki );
|
||||
}
|
||||
// Figure out which server to use
|
||||
$replicaDB = $this->getOption( 'replicadb', $this->getOption( 'slave', '' ) );
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
require_once __DIR__ . '/../Maintenance.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Maintenance script that shows some statistics on the blob_orphans table,
|
||||
* created with trackBlobs.php.
|
||||
|
|
@ -37,7 +39,8 @@ class OrphanStats extends Maintenance {
|
|||
}
|
||||
|
||||
protected function &getDB( $cluster, $groups = [], $wiki = false ) {
|
||||
$lb = wfGetLBFactory()->getExternalLB( $cluster );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lb = $lbFactory->getExternalLB( $cluster );
|
||||
|
||||
return $lb->getConnection( DB_REPLICA );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -643,7 +643,8 @@ class RecompressTracked {
|
|||
* @return Database
|
||||
*/
|
||||
function getExtDB( $cluster ) {
|
||||
$lb = wfGetLBFactory()->getExternalLB( $cluster );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lb = $lbFactory->getExternalLB( $cluster );
|
||||
|
||||
return $lb->getConnection( DB_MASTER );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
* @see wfWaitForSlaves()
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\DBConnectionError;
|
||||
|
||||
require __DIR__ . '/../commandLine.inc';
|
||||
|
|
@ -317,7 +318,8 @@ class TrackBlobs {
|
|||
|
||||
foreach ( $this->clusters as $cluster ) {
|
||||
echo "Searching for orphan blobs in $cluster...\n";
|
||||
$lb = wfGetLBFactory()->getExternalLB( $cluster );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lb = $lbFactory->getExternalLB( $cluster );
|
||||
try {
|
||||
$extDB = $lb->getConnection( DB_REPLICA );
|
||||
} catch ( DBConnectionError $e ) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ define( 'MW_PARSER_TEST', true );
|
|||
|
||||
require __DIR__ . '/../../maintenance/Maintenance.php';
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
class ParserTestsMaintenance extends Maintenance {
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
|
|
@ -145,7 +147,8 @@ class ParserTestsMaintenance extends Maintenance {
|
|||
|
||||
$recorderLB = false;
|
||||
if ( $record || $compare ) {
|
||||
$recorderLB = wfGetLBFactory()->newMainLB();
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$recorderLB = $lbFactory->newMainLB();
|
||||
// This connection will have the wiki's table prefix, not parsertest_
|
||||
$recorderDB = $recorderLB->getConnection( DB_MASTER );
|
||||
|
||||
|
|
|
|||
|
|
@ -207,7 +207,8 @@ class DeferredUpdatesTest extends MediaWikiTestCase {
|
|||
];
|
||||
|
||||
// clear anything
|
||||
wfGetLBFactory()->commitMasterChanges( __METHOD__ );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lbFactory->commitMasterChanges( __METHOD__ );
|
||||
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( $updates ) {
|
||||
|
|
@ -271,7 +272,8 @@ class DeferredUpdatesTest extends MediaWikiTestCase {
|
|||
$x = false;
|
||||
$y = false;
|
||||
// clear anything
|
||||
wfGetLBFactory()->commitMasterChanges( __METHOD__ );
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lbFactory->commitMasterChanges( __METHOD__ );
|
||||
|
||||
DeferredUpdates::addCallableUpdate(
|
||||
function () use ( &$x, &$y ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue