MediaWiki  1.23.6
getSlaveServer.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Maintenance.php';
25 
31 class GetSlaveServer extends Maintenance {
32  public function __construct() {
33  parent::__construct();
34  $this->addOption( "group", "Query group to check specifically" );
35  $this->mDescription = "Report the hostname of a slave server";
36  }
37  public function execute() {
38  global $wgAllDBsAreLocalhost;
39  if ( $wgAllDBsAreLocalhost ) {
40  $host = 'localhost';
41  } elseif ( $this->hasOption( 'group' ) ) {
42  $db = wfGetDB( DB_SLAVE, $this->getOption( 'group' ) );
43  $host = $db->getServer();
44  } else {
45  $lb = wfGetLB();
46  $i = $lb->getReaderIndex();
47  $host = $lb->getServerName( $i );
48  }
49  $this->output( "$host\n" );
50  }
51 }
52 
53 $maintClass = "GetSlaveServer";
54 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3669
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
$maintClass
$maintClass
Definition: getSlaveServer.php:53
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$lb
if( $wgAPIRequestLog) $lb
Definition: api.php:126
GetSlaveServer\execute
execute()
Do the actual work.
Definition: getSlaveServer.php:37
GetSlaveServer
Maintenance script that reports the hostname of a slave server.
Definition: getSlaveServer.php:31
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
GetSlaveServer\__construct
__construct()
Default constructor.
Definition: getSlaveServer.php:32
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181