40 static $typesWithSchema = [
'postgres',
'msssql' ];
44 $mainConfig->
get(
'DBname' ),
46 $mainConfig->
get(
'DBprefix' )
50 'replLogger' => LoggerFactory::getInstance(
'DBReplication' ),
51 'queryLogger' => LoggerFactory::getInstance(
'DBQuery' ),
52 'connLogger' => LoggerFactory::getInstance(
'DBConnection' ),
53 'perfLogger' => LoggerFactory::getInstance(
'DBPerformance' ),
61 if ( $lbConf[
'class'] ===
'LBFactorySimple' ) {
62 if ( isset( $lbConf[
'servers'] ) ) {
64 } elseif ( is_array( $mainConfig->
get(
'DBservers' ) ) ) {
65 foreach ( $mainConfig->
get(
'DBservers' )
as $i => $server ) {
66 if ( $server[
'type'] ===
'sqlite' ) {
67 $server += [
'dbDirectory' => $mainConfig->
get(
'SQLiteDataDir' ) ];
68 } elseif ( $server[
'type'] ===
'postgres' ) {
69 $server += [
'port' => $mainConfig->
get(
'DBport' ) ];
71 if ( in_array( $server[
'type'], $typesWithSchema,
true ) ) {
72 $server += [
'schema' => $mainConfig->
get(
'DBmwschema' ) ];
76 'tablePrefix' => $mainConfig->
get(
'DBprefix' ),
78 'sqlMode' => $mainConfig->
get(
'SQLMode' ),
79 'utf8Mode' => $mainConfig->
get(
'DBmysql5' )
82 $lbConf[
'servers'][$i] = $server;
90 'host' => $mainConfig->
get(
'DBserver' ),
91 'user' => $mainConfig->
get(
'DBuser' ),
92 'password' => $mainConfig->
get(
'DBpassword' ),
93 'dbname' => $mainConfig->
get(
'DBname' ),
94 'tablePrefix' => $mainConfig->
get(
'DBprefix' ),
95 'type' => $mainConfig->
get(
'DBtype' ),
98 'sqlMode' => $mainConfig->
get(
'SQLMode' ),
99 'utf8Mode' => $mainConfig->
get(
'DBmysql5' )
101 if ( in_array( $server[
'type'], $typesWithSchema,
true ) ) {
102 $server += [
'schema' => $mainConfig->
get(
'DBmwschema' ) ];
104 if ( $server[
'type'] ===
'sqlite' ) {
105 $server[
'dbDirectory'] = $mainConfig->
get(
'SQLiteDataDir' );
106 } elseif ( $server[
'type'] ===
'postgres' ) {
107 $server[
'port'] = $mainConfig->
get(
'DBport' );
109 $lbConf[
'servers'] = [ $server ];
111 if ( !isset( $lbConf[
'externalClusters'] ) ) {
112 $lbConf[
'externalClusters'] = $mainConfig->
get(
'ExternalServers' );
114 } elseif ( $lbConf[
'class'] ===
'LBFactoryMulti' ) {
115 if ( isset( $lbConf[
'serverTemplate'] ) ) {
116 if ( in_array( $lbConf[
'serverTemplate'][
'type'], $typesWithSchema,
true ) ) {
117 $lbConf[
'serverTemplate'][
'schema'] = $mainConfig->
get(
'DBmwschema' );
119 $lbConf[
'serverTemplate'][
'sqlMode'] = $mainConfig->
get(
'SQLMode' );
120 $lbConf[
'serverTemplate'][
'utf8Mode'] = $mainConfig->
get(
'DBmysql5' );
125 $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
126 if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
127 $lbConf[
'srvCache'] = $sCache;
130 if ( $cCache->getQoS( $cCache::ATTR_EMULATION ) > $cCache::QOS_EMULATION_SQL ) {
131 $lbConf[
'memCache'] = $cCache;
133 $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
134 if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
135 $lbConf[
'wanCache'] = $wCache;
153 'LBFactory_Simple' =>
'LBFactorySimple',
154 'LBFactory_Single' =>
'LBFactorySingle',
155 'LBFactory_Multi' =>
'LBFactoryMulti'
158 $class = $config[
'class'];
160 if ( isset( $bcClasses[$class] ) ) {
161 $class = $bcClasses[$class];
163 '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details',
the array() calling protocol came about after MediaWiki 1.4rc1.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static instance()
Singleton.
wfHostname()
Fetch server name for use in error reporting etc.
static getLocalClusterInstance()
Get the main cluster-local cache object.
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 MediaWikiServices
it s the revision text itself In either if gzip is the revision text is gzipped $flags
when a variable name is used in a it is silently declared as a new local masking the global
get($name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Class to handle database/prefix specification for IDatabase domains.
global $wgCommandLineMode
wfConfiguredReadOnlyReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
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
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
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method.MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances.The"Spi"in MediaWiki\Logger\Spi stands for"service provider interface".An SPI is an API intended to be implemented or extended by a third party.This software design pattern is intended to enable framework extension and replaceable components.It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki.The service provider interface allows the backend logging library to be implemented in multiple ways.The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime.This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance.Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
MediaWiki-specific class for generating database load balancers.
static applyDefaultConfig(array $lbConf, Config $mainConfig)