Go to the documentation of this file.
26 use InvalidArgumentException;
164 parent::__construct( $conf );
166 $required = [
'sectionsByDB',
'sectionLoads',
'serverTemplate' ];
167 $optional = [
'groupLoadsBySection',
'groupLoadsByDB',
'hostsByName',
168 'externalLoads',
'externalTemplateOverrides',
'templateOverridesByServer',
169 'templateOverridesByCluster',
'templateOverridesBySection',
'masterTemplateOverrides',
170 'readOnlyBySection',
'loadMonitorClass' ];
172 foreach ( $required
as $key ) {
173 if ( !isset( $conf[$key] ) ) {
174 throw new InvalidArgumentException( __CLASS__ .
": $key is required." );
176 $this->$key = $conf[$key];
179 foreach ( $optional
as $key ) {
180 if ( isset( $conf[$key] ) ) {
181 $this->$key = $conf[$key];
191 if ( $this->lastDomain === $domain ) {
195 $section = $this->sectionsByDB[$dbName] ??
'DEFAULT';
197 $this->lastDomain = $domain;
209 $groupLoads = $this->groupLoadsByDB[$dbName] ?? [];
211 if ( isset( $this->groupLoadsBySection[
$section] ) ) {
212 $groupLoads = array_merge_recursive(
213 $groupLoads, $this->groupLoadsBySection[
$section] );
223 if ( isset( $this->templateOverridesBySection[
$section] ) ) {
241 if ( !isset( $this->mainLBs[
$section] ) ) {
249 if ( !isset( $this->externalLoads[$cluster] ) ) {
250 throw new InvalidArgumentException( __METHOD__ .
": Unknown cluster \"$cluster\"" );
253 if ( $this->externalTemplateOverrides ) {
256 if ( isset( $this->templateOverridesByCluster[$cluster] ) ) {
262 $this->externalLoads[$cluster],
264 $this->readOnlyReason
269 if ( !isset( $this->extLBs[$cluster] ) ) {
273 return $this->extLBs[$cluster];
278 foreach ( $this->sectionsByDB
as $db =>
$section ) {
289 foreach ( $this->externalLoads
as $cluster => $unused ) {
310 'loadMonitor' => [
'class' => $this->loadMonitorClass ],
331 foreach ( $groupLoadsByServer
as $server => $stuff ) {
332 if ( !isset( $loads[$server] ) ) {
336 foreach ( $loads
as $serverName => $load ) {
339 $serverInfo[
'master'] =
true;
340 if ( $this->masterTemplateOverrides ) {
341 $serverInfo = $this->masterTemplateOverrides + $serverInfo;
345 $serverInfo[
'replica'] =
true;
347 if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
348 $serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;
350 if ( isset( $groupLoadsByServer[$serverName] ) ) {
351 $serverInfo[
'groupLoads'] = $groupLoadsByServer[$serverName];
353 $serverInfo[
'host'] = $this->hostsByName[$serverName] ?? $serverName;
354 $serverInfo[
'hostName'] = $serverName;
355 $serverInfo[
'load'] = $load;
358 $servers[] = $serverInfo;
371 foreach ( $groupLoads
as $group => $loads ) {
372 foreach ( $loads
as $server => $load ) {
373 $reindexed[$server][$group] = $load;
385 $domain = ( $domain ===
false )
389 return [ $domain->getDatabase(), $domain->getTablePrefix() ];
400 foreach ( $this->mainLBs
as $lb ) {
403 foreach ( $this->extLBs
as $lb ) {
processing should stop and the error should be shown to the user * false
static newFromId( $domain)
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
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
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
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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