56 static $typesWithSchema = [
'postgres',
'msssql' ];
60 $mainConfig->get(
'DBname' ),
61 $mainConfig->get(
'DBmwschema' ),
62 $mainConfig->get(
'DBprefix' )
64 'profiler' =>
function (
$section ) {
65 return Profiler::instance()->scopedProfileIn(
$section );
67 'trxProfiler' => Profiler::instance()->getTransactionProfiler(),
68 'replLogger' => LoggerFactory::getInstance(
'DBReplication' ),
69 'queryLogger' => LoggerFactory::getInstance(
'DBQuery' ),
70 'connLogger' => LoggerFactory::getInstance(
'DBConnection' ),
71 'perfLogger' => LoggerFactory::getInstance(
'DBPerformance' ),
72 'errorLogger' => [ MWExceptionHandler::class,
'logException' ],
73 'deprecationLogger' => [ static::class,
'logDeprecation' ],
76 'readOnlyReason' => $readOnlyMode->
getReason(),
77 'defaultGroup' => $mainConfig->get(
'DBDefaultGroup' ),
84 if ( $lbConf[
'class'] ===
Wikimedia\Rdbms\LBFactorySimple::class ) {
85 $httpMethod = $_SERVER[
'REQUEST_METHOD'] ??
null;
89 $isReadRequest =
in_array( $httpMethod, [
'GET',
'HEAD',
'OPTIONS',
'TRACE' ] );
91 if (
isset( $lbConf[
'servers'] ) ) {
94 $lbConf[
'servers'] = [];
95 foreach ( $mainConfig->get(
'DBservers' ) as $i => $server ) {
96 if ( $server[
'type'] ===
'sqlite' ) {
98 'dbDirectory' => $mainConfig->get(
'SQLiteDataDir' ),
99 'trxMode' => $isReadRequest ?
'DEFERRED' :
'IMMEDIATE'
101 }
elseif ( $server[
'type'] ===
'postgres' ) {
103 'port' => $mainConfig->get(
'DBport' ),
105 'keywordTableMap' => [
'user' =>
'mwuser',
'text' =>
'pagecontent' ]
107 }
elseif ( $server[
'type'] ===
'mssql' ) {
109 'port' => $mainConfig->get(
'DBport' ),
110 'useWindowsAuth' => $mainConfig->get(
'DBWindowsAuthentication' )
114 if (
in_array( $server[
'type'], $typesWithSchema,
true ) ) {
115 $server += [
'schema' => $mainConfig->get(
'DBmwschema' ) ];
119 'tablePrefix' => $mainConfig->get(
'DBprefix' ),
121 'sqlMode' => $mainConfig->get(
'SQLMode' ),
124 $lbConf[
'servers'][
$i] = $server;
128 $flags |= $mainConfig->get(
'DebugDumpSql' ) ?
DBO_DEBUG : 0;
129 $flags |= $mainConfig->get(
'DBssl' ) ?
DBO_SSL : 0;
130 $flags |= $mainConfig->get(
'DBcompress' ) ?
DBO_COMPRESS : 0;
132 'host' => $mainConfig->get(
'DBserver' ),
133 'user' => $mainConfig->get(
'DBuser' ),
134 'password' => $mainConfig->get(
'DBpassword' ),
135 'dbname' => $mainConfig->get(
'DBname' ),
136 'tablePrefix' => $mainConfig->get(
'DBprefix' ),
137 'type' => $mainConfig->get(
'DBtype' ),
140 'sqlMode' => $mainConfig->get(
'SQLMode' ),
141 'trxMode' => $isReadRequest ?
'DEFERRED' :
'IMMEDIATE'
143 if (
in_array( $server[
'type'], $typesWithSchema,
true ) ) {
144 $server += [
'schema' => $mainConfig->get(
'DBmwschema' ) ];
146 if ( $server[
'type'] ===
'sqlite' ) {
147 $server[
'dbDirectory'] = $mainConfig->get(
'SQLiteDataDir' );
148 }
elseif ( $server[
'type'] ===
'postgres' ) {
149 $server[
'port'] = $mainConfig->get(
'DBport' );
151 $server[
'keywordTableMap'] = [
'user' =>
'mwuser',
'text' =>
'pagecontent' ];
152 }
elseif ( $server[
'type'] ===
'mssql' ) {
153 $server[
'port'] = $mainConfig->get(
'DBport' );
154 $server[
'useWindowsAuth'] = $mainConfig->get(
'DBWindowsAuthentication' );
156 $lbConf[
'servers'] = [ $server ];
158 if ( !
isset( $lbConf[
'externalClusters'] ) ) {
159 $lbConf[
'externalClusters'] = $mainConfig->get(
'ExternalServers' );
162 $serversCheck = $lbConf[
'servers'];
163 }
elseif ( $lbConf[
'class'] ===
Wikimedia\Rdbms\LBFactoryMulti::class ) {
164 if (
isset( $lbConf[
'serverTemplate'] ) ) {
165 if (
in_array( $lbConf[
'serverTemplate'][
'type'], $typesWithSchema,
true ) ) {
166 $lbConf[
'serverTemplate'][
'schema'] = $mainConfig->get(
'DBmwschema' );
168 $lbConf[
'serverTemplate'][
'sqlMode'] = $mainConfig->get(
'SQLMode' );
170 $serversCheck = $lbConf[
'serverTemplate'] ?? [];
190 if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
193 if ( $mStash->getQoS( $mStash::ATTR_EMULATION ) > $mStash::QOS_EMULATION_SQL ) {
196 if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
208 $ldDB = $mainConfig->get(
'DBname' );
209 $ldTP = $mainConfig->get(
'DBprefix' );
211 foreach ( $servers as $server ) {
212 $type = $server[
'type'] ??
null;
213 $srvDB = $server[
'dbname'] ??
null;
214 $srvTP = $server[
'tablePrefix'] ??
'';
216 if (
$type ===
'mysql' ) {
219 if ( $srvDB !==
null && $srvDB !== $ldDB ) {
223 if ( $srvTP !==
'' ) {
228 if ( $srvTP !==
'' && $srvTP !== $ldTP ) {
239 $e =
new UnexpectedValueException(
240 "\$wgDBprefix is set to '$prefix' but the database type is '$dbType'. " .
241 "MediaWiki does not support using a table prefix with this RDBMS type."
252 $e =
new UnexpectedValueException(
253 "\$wgDBservers has dbname='$srvDB' but \$wgDBname='$ldDB'. " .
254 "Set \$wgDBname to the database used by this wiki project. " .
255 "There is rarely a need to set 'dbname' in \$wgDBservers. " .
256 "Cross-wiki database access, use of WikiMap::getCurrentWikiDbDomain(), " .
257 "use of Database::getDomainId(), and other features are not reliable when " .
258 "\$wgDBservers does not match the local wiki database/prefix."
269 $e =
new UnexpectedValueException(
270 "\$wgDBservers has tablePrefix='$srvTP' but \$wgDBprefix='$ldTP'. " .
271 "Set \$wgDBprefix to the table prefix used by this wiki project. " .
272 "There is rarely a need to set 'tablePrefix' in \$wgDBservers. " .
273 "Cross-wiki database access, use of WikiMap::getCurrentWikiDbDomain(), " .
274 "use of Database::getDomainId(), and other features are not reliable when " .
275 "\$wgDBservers does not match the local wiki database/prefix."
293 'LBFactory_Simple' =>
'LBFactorySimple',
294 'LBFactory_Single' =>
'LBFactorySingle',
295 'LBFactory_Multi' =>
'LBFactoryMulti'
298 $class = $config[
'class'];
300 if (
isset( $bcClasses[$class] ) ) {
301 $class = $bcClasses[$class];
303 '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details',
310 'LBFactorySingle' => Wikimedia\Rdbms\LBFactorySingle::class,
311 'LBFactorySimple' => Wikimedia\Rdbms\LBFactorySimple::class,
312 'LBFactoryMulti' => Wikimedia\Rdbms\LBFactoryMulti::class
315 if (
isset( $compat[$class] ) ) {
316 $class = $compat[$class];
323 if ( $config->
get(
'DBtype' ) ===
'mysql' ) {
339 'ar_usertext_timestamp' =>
'usertext_timestamp',
340 'un_user_id' =>
'user_id',
341 'un_user_ip' =>
'user_ip',
353 if (
isset( self::$loggedDeprecations[$msg] ) ) {
356 self::$loggedDeprecations[$msg] =
true;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$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.
Class representing a cache/ephemeral data store.
static output( $e, $mode, $eNew=null)
MediaWiki-specific class for generating database load balancers.
static applyDefaultCaching(array $lbConf, BagOStuff $sCache, BagOStuff $mStash, WANObjectCache $wCache)
static logDeprecation( $msg)
Log a database deprecation warning.
static sanityCheckServerConfig(array $servers, Config $mainConfig)
static applyDefaultConfig(array $lbConf, Config $mainConfig, ConfiguredReadOnlyMode $readOnlyMode, BagOStuff $srvCace, BagOStuff $mainStash, WANObjectCache $wanCache)
static array $loggedDeprecations
Cache of already-logged deprecation messages.
static reportMismatchedPrefixes( $srvTP, $ldTP)
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
static reportMismatchedDBs( $srvDB, $ldDB)
static setSchemaAliases(LBFactory $lbFactory, Config $config)
static reportIfPrefixSet( $prefix, $dbType)
Multi-datacenter aware caching interface.
Class to handle database/prefix specification for IDatabase domains.
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
returning false will NOT prevent logging $e
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
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))