170 parent::__construct( $conf );
173 $required = [
'sectionsByDB',
'sectionLoads',
'serverTemplate' ];
174 $optional = [
'groupLoadsBySection',
'groupLoadsByDB',
'hostsByName',
175 'externalLoads',
'externalTemplateOverrides',
'templateOverridesByServer',
176 'templateOverridesByCluster',
'templateOverridesBySection',
'masterTemplateOverrides',
177 'readOnlyBySection',
'loadMonitorClass' ];
179 foreach ( $required
as $key ) {
180 if ( !isset( $conf[$key] ) ) {
181 throw new MWException( __CLASS__ .
": $key is required in configuration" );
183 $this->$key = $conf[$key];
186 foreach ( $optional
as $key ) {
187 if ( isset( $conf[$key] ) ) {
188 $this->$key = $conf[$key];
198 if ( $this->lastWiki === $wiki ) {
202 if ( isset( $this->sectionsByDB[$dbName] ) ) {
203 $section = $this->sectionsByDB[$dbName];
208 $this->lastWiki = $wiki;
220 if ( isset( $this->groupLoadsByDB[$dbName] ) ) {
221 $groupLoads = $this->groupLoadsByDB[$dbName];
226 if ( isset( $this->groupLoadsBySection[
$section] ) ) {
227 $groupLoads = array_merge_recursive( $groupLoads, $this->groupLoadsBySection[$section] );
232 if (
$readOnlyReason ===
false && isset( $this->readOnlyBySection[$section] ) ) {
237 if ( isset( $this->templateOverridesBySection[$section] ) ) {
243 $this->sectionLoads[$section],
255 if ( !isset( $this->mainLBs[
$section] ) ) {
257 $lb->parentInfo( [
'id' =>
"main-$section" ] );
258 $this->chronProt->initLB( $lb );
272 if ( !isset( $this->externalLoads[$cluster] ) ) {
273 throw new MWException( __METHOD__ .
": Unknown cluster \"$cluster\"" );
276 if ( isset( $this->externalTemplateOverrides ) ) {
279 if ( isset( $this->templateOverridesByCluster[$cluster] ) ) {
285 $this->externalLoads[$cluster],
287 $this->readOnlyReason
297 if ( !isset( $this->extLBs[$cluster] ) ) {
298 $this->extLBs[$cluster] = $this->
newExternalLB( $cluster, $wiki );
299 $this->extLBs[$cluster]->parentInfo( [
'id' =>
"ext-$cluster" ] );
300 $this->chronProt->initLB( $this->extLBs[$cluster] );
303 return $this->extLBs[$cluster];
318 'loadMonitor' => $this->loadMonitorClass,
320 'trxProfiler' => $this->trxProfiler
336 foreach ( $groupLoadsByServer
as $server => $stuff ) {
337 if ( !isset( $loads[$server] ) ) {
341 foreach ( $loads
as $serverName => $load ) {
344 $serverInfo[
'master'] =
true;
345 if ( isset( $this->masterTemplateOverrides ) ) {
346 $serverInfo = $this->masterTemplateOverrides + $serverInfo;
350 $serverInfo[
'slave'] =
true;
352 if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
353 $serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;
355 if ( isset( $groupLoadsByServer[$serverName] ) ) {
356 $serverInfo[
'groupLoads'] = $groupLoadsByServer[$serverName];
358 if ( isset( $this->hostsByName[$serverName] ) ) {
359 $serverInfo[
'host'] = $this->hostsByName[$serverName];
361 $serverInfo[
'host'] = $serverName;
363 $serverInfo[
'hostName'] = $serverName;
364 $serverInfo[
'load'] = $load;
365 $servers[] = $serverInfo;
378 foreach ( $groupLoads
as $group => $loads ) {
379 foreach ( $loads
as $server => $load ) {
380 $reindexed[$server][$group] = $load;
393 if ( $wiki ===
false ) {
410 foreach ( $this->mainLBs
as $lb ) {
411 call_user_func_array( $callback, array_merge( [ $lb ],
$params ) );
413 foreach ( $this->extLBs
as $lb ) {
414 call_user_func_array( $callback, array_merge( [ $lb ],
$params ) );
419 if ( !(
$flags & self::SHUTDOWN_NO_CHRONPROT ) ) {
array $groupLoadsBySection
A 3-d map giving server load ratios for each section and group.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
the array() calling protocol came about after MediaWiki 1.4rc1.
shutdownChronologyProtector(ChronologyProtector $cp)
array $serverTemplate
A server info associative array as documented for $wgDBservers.
array $templateOverridesBySection
A 2-d map overriding the server info by section.
newLoadBalancer($template, $loads, $groupLoads, $readOnlyReason)
Make a new load balancer object based on template and load array.
getSectionForWiki($wiki=false)
newExternalLB($cluster, $wiki=false)
it s the revision text itself In either if gzip is the revision text is gzipped $flags
A multi-wiki, multi-master factory for Wikimedia and similar installations.
when a variable name is used in a it is silently declared as a new local masking the global
array $templateOverridesByServer
A 2-d map overriding serverTemplate and externalTemplateOverrides on a server-by-server basis...
commitMasterChanges($fname=__METHOD__, array $options=[])
Commit changes on all master connections.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
Database load balancing object.
An interface for generating database load balancers.
array $templateOverridesByCluster
A 2-d map overriding the server info by external storage cluster.
array $sectionLoads
A 2-d map.
string bool $readOnlyReason
Reason all LBs are read-only or false if not.
getDBNameAndPrefix($wiki=false)
Get the database name and prefix based on the wiki ID.
array $externalTemplateOverrides
A set of server info keys overriding serverTemplate for external storage.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
array $sectionsByDB
A map of database names to section names.
array $conf
Load balancer factory configuration.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
makeServerArray($template, $loads, $groupLoads)
Make a server array as expected by LoadBalancer::__construct, using a template and load array...
array $hostsByName
A map of hostname to IP address.
array $masterTemplateOverrides
An override array for all master servers.
array bool $readOnlyBySection
A map of section name to read-only message.
$wgDBprefix
Table name prefix.
array $externalLoads
A map of external storage cluster name to server load map.
wfSplitWikiID($wiki)
Split a wiki ID into DB name and table prefix.
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname
& getExternalLB($cluster, $wiki=false)
reindexGroupLoads($groupLoads)
Take a group load array indexed by group then server, and reindex it by server then group...
forEachLB($callback, array $params=[])
Execute a function for each tracked load balancer The callback is called with the load balancer as th...
array $groupLoadsByDB
A 3-d map giving server load ratios by DB name.