X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FgetReplicaServer.php;h=7e9104cceacad26a2c503329e819c2c8946bfbcb;hb=75e1edeacd5c976354ecac4e8056716fb82569e4;hp=43e876ea071119cb02633aeb07bc58a535ca3210;hpb=236488d398046838059f758b0915341648b64c7b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/getReplicaServer.php b/maintenance/getReplicaServer.php index 43e876ea07..7e9104ccea 100644 --- a/maintenance/getReplicaServer.php +++ b/maintenance/getReplicaServer.php @@ -23,12 +23,14 @@ require_once __DIR__ . '/Maintenance.php'; +use MediaWiki\MediaWikiServices; + /** * Maintenance script that reports the hostname of a replica DB server. * * @ingroup Maintenance */ -class GetSlaveServer extends Maintenance { +class GetReplicaServer extends Maintenance { public function __construct() { parent::__construct(); $this->addOption( "group", "Query group to check specifically" ); @@ -36,14 +38,11 @@ class GetSlaveServer extends Maintenance { } public function execute() { - global $wgAllDBsAreLocalhost; - if ( $wgAllDBsAreLocalhost ) { - $host = 'localhost'; - } elseif ( $this->hasOption( 'group' ) ) { + if ( $this->hasOption( 'group' ) ) { $db = $this->getDB( DB_REPLICA, $this->getOption( 'group' ) ); $host = $db->getServer(); } else { - $lb = wfGetLB(); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); $i = $lb->getReaderIndex(); $host = $lb->getServerName( $i ); } @@ -51,5 +50,5 @@ class GetSlaveServer extends Maintenance { } } -$maintClass = GetSlaveServer::class; +$maintClass = GetReplicaServer::class; require_once RUN_MAINTENANCE_IF_MAIN;