49 static $typesWithSchema = [
'postgres',
'msssql' ];
53 $mainConfig->get(
'DBname' ),
54 $mainConfig->get(
'DBmwschema' ),
55 $mainConfig->get(
'DBprefix' )
57 'profiler' => Profiler::instance(),
58 'trxProfiler' => Profiler::instance()->getTransactionProfiler(),
59 'replLogger' => LoggerFactory::getInstance(
'DBReplication' ),
60 'queryLogger' => LoggerFactory::getInstance(
'DBQuery' ),
61 'connLogger' => LoggerFactory::getInstance(
'DBConnection' ),
62 'perfLogger' => LoggerFactory::getInstance(
'DBPerformance' ),
63 'errorLogger' => [ MWExceptionHandler::class,
'logException' ],
64 'deprecationLogger' => [ static::class,
'logDeprecation' ],
67 'readOnlyReason' => $readOnlyMode->
getReason(),
73 if ( $lbConf[
'class'] === Wikimedia\Rdbms\LBFactorySimple::class ) {
74 if ( isset( $lbConf[
'servers'] ) ) {
76 } elseif ( is_array( $mainConfig->get(
'DBservers' ) ) ) {
77 foreach ( $mainConfig->get(
'DBservers' ) as $i => $server ) {
78 if ( $server[
'type'] ===
'sqlite' ) {
79 $server += [
'dbDirectory' => $mainConfig->get(
'SQLiteDataDir' ) ];
80 } elseif ( $server[
'type'] ===
'postgres' ) {
82 'port' => $mainConfig->get(
'DBport' ),
84 'keywordTableMap' => [
'user' =>
'mwuser',
'text' =>
'pagecontent' ]
86 } elseif ( $server[
'type'] ===
'mssql' ) {
88 'port' => $mainConfig->get(
'DBport' ),
89 'useWindowsAuth' => $mainConfig->get(
'DBWindowsAuthentication' )
93 if ( in_array( $server[
'type'], $typesWithSchema,
true ) ) {
94 $server += [
'schema' => $mainConfig->get(
'DBmwschema' ) ];
98 'tablePrefix' => $mainConfig->get(
'DBprefix' ),
100 'sqlMode' => $mainConfig->get(
'SQLMode' ),
101 'utf8Mode' => $mainConfig->get(
'DBmysql5' )
104 $lbConf[
'servers'][$i] = $server;
108 $flags |= $mainConfig->get(
'DebugDumpSql' ) ?
DBO_DEBUG : 0;
109 $flags |= $mainConfig->get(
'DBssl' ) ?
DBO_SSL : 0;
110 $flags |= $mainConfig->get(
'DBcompress' ) ?
DBO_COMPRESS : 0;
112 'host' => $mainConfig->get(
'DBserver' ),
113 'user' => $mainConfig->get(
'DBuser' ),
114 'password' => $mainConfig->get(
'DBpassword' ),
115 'dbname' => $mainConfig->get(
'DBname' ),
116 'tablePrefix' => $mainConfig->get(
'DBprefix' ),
117 'type' => $mainConfig->get(
'DBtype' ),
120 'sqlMode' => $mainConfig->get(
'SQLMode' ),
121 'utf8Mode' => $mainConfig->get(
'DBmysql5' )
123 if ( in_array( $server[
'type'], $typesWithSchema,
true ) ) {
124 $server += [
'schema' => $mainConfig->get(
'DBmwschema' ) ];
126 if ( $server[
'type'] ===
'sqlite' ) {
127 $server[
'dbDirectory'] = $mainConfig->get(
'SQLiteDataDir' );
128 } elseif ( $server[
'type'] ===
'postgres' ) {
129 $server[
'port'] = $mainConfig->get(
'DBport' );
131 $server[
'keywordTableMap'] = [
'user' =>
'mwuser',
'text' =>
'pagecontent' ];
132 } elseif ( $server[
'type'] ===
'mssql' ) {
133 $server[
'port'] = $mainConfig->get(
'DBport' );
134 $server[
'useWindowsAuth'] = $mainConfig->get(
'DBWindowsAuthentication' );
136 $lbConf[
'servers'] = [ $server ];
138 if ( !isset( $lbConf[
'externalClusters'] ) ) {
139 $lbConf[
'externalClusters'] = $mainConfig->get(
'ExternalServers' );
141 } elseif ( $lbConf[
'class'] === Wikimedia\Rdbms\LBFactoryMulti::class ) {
142 if ( isset( $lbConf[
'serverTemplate'] ) ) {
143 if ( in_array( $lbConf[
'serverTemplate'][
'type'], $typesWithSchema,
true ) ) {
144 $lbConf[
'serverTemplate'][
'schema'] = $mainConfig->get(
'DBmwschema' );
146 $lbConf[
'serverTemplate'][
'sqlMode'] = $mainConfig->get(
'SQLMode' );
147 $lbConf[
'serverTemplate'][
'utf8Mode'] = $mainConfig->get(
'DBmysql5' );
151 $services = MediaWikiServices::getInstance();
154 $sCache =
$services->getLocalServerObjectCache();
155 if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
156 $lbConf[
'srvCache'] = $sCache;
158 $mStash =
$services->getMainObjectStash();
159 if ( $mStash->getQoS( $mStash::ATTR_EMULATION ) > $mStash::QOS_EMULATION_SQL ) {
160 $lbConf[
'memStash'] = $mStash;
162 $wCache =
$services->getMainWANObjectCache();
163 if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
164 $lbConf[
'wanCache'] = $wCache;
182 'LBFactory_Simple' =>
'LBFactorySimple',
183 'LBFactory_Single' =>
'LBFactorySingle',
184 'LBFactory_Multi' =>
'LBFactoryMulti'
187 $class = $config[
'class'];
189 if ( isset( $bcClasses[$class] ) ) {
190 $class = $bcClasses[$class];
192 '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details',
199 'LBFactorySingle' => Wikimedia\Rdbms\LBFactorySingle::class,
200 'LBFactorySimple' => Wikimedia\Rdbms\LBFactorySimple::class,
201 'LBFactoryMulti' => Wikimedia\Rdbms\LBFactoryMulti::class
204 if ( isset( $compat[$class] ) ) {
205 $class = $compat[$class];
212 if ( $config->
get(
'DBtype' ) ===
'mysql' ) {
227 $lbFactory->setIndexAliases( [
228 'ar_usertext_timestamp' =>
'usertext_timestamp',
229 'un_user_id' =>
'user_id',
230 'un_user_ip' =>
'user_ip',
242 if ( isset( self::$loggedDeprecations[$msg] ) ) {
245 self::$loggedDeprecations[$msg] =
true;
248 trigger_error( $msg, E_USER_DEPRECATED );
$wgDevelopmentWarnings
If set to true MediaWiki will throw notices for some possible error conditions and for deprecated fun...
global $wgCommandLineMode
wfHostname()
Fetch server name for use in error reporting etc.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
MediaWiki-specific class for generating database load balancers.
static applyDefaultConfig(array $lbConf, Config $mainConfig, ConfiguredReadOnlyMode $readOnlyMode)
static logDeprecation( $msg)
Log a database deprecation warning.
static array $loggedDeprecations
Cache of already-logged deprecation messages.
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
static setSchemaAliases(LBFactory $lbFactory, Config $config)
Class to handle database/prefix specification for IDatabase domains.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".