MediaWiki REL1_37
MWLBFactory Class Reference

MediaWiki-specific class for generating database load balancers. More...

Static Public Member Functions

static applyDefaultConfig (array $lbConf, ServiceOptions $options, ConfiguredReadOnlyMode $readOnlyMode, BagOStuff $cpStash, BagOStuff $srvCache, WANObjectCache $wanCache, CriticalSectionProvider $csProvider)
 
static applyGlobalState (ILBFactory $lbFactory, Config $config, IBufferingStatsdDataFactory $stats)
 Apply global state from the current web request or other PHP process.
 
static getLBFactoryClass (array $config)
 Decide which LBFactory class to use.
 
static logDeprecation ( $msg)
 Log a database deprecation warning.
 
static setDomainAliases (ILBFactory $lbFactory)
 

Public Attributes

const APPLY_DEFAULT_CONFIG_OPTIONS
 

Static Private Member Functions

static assertValidServerConfigs (array $servers, $ldDB, $ldTP)
 
static getDbTypesWithSchemas ()
 
static initServerInfo (array $server, ServiceOptions $options)
 
static reportIfPrefixSet ( $prefix, $dbType)
 
static reportMismatchedDBs ( $srvDB, $ldDB)
 
static reportMismatchedPrefixes ( $srvTP, $ldTP)
 

Static Private Attributes

static array $loggedDeprecations = []
 Cache of already-logged deprecation messages.
 

Detailed Description

MediaWiki-specific class for generating database load balancers.

Access: internal
For use by core ServiceWiring only.

Definition at line 39 of file MWLBFactory.php.

Member Function Documentation

◆ applyDefaultConfig()

static MWLBFactory::applyDefaultConfig ( array  $lbConf,
ServiceOptions  $options,
ConfiguredReadOnlyMode  $readOnlyMode,
BagOStuff  $cpStash,
BagOStuff  $srvCache,
WANObjectCache  $wanCache,
CriticalSectionProvider  $csProvider 
)
static
Parameters
array$lbConfConfig for LBFactory::__construct()
ServiceOptions$options
ConfiguredReadOnlyMode$readOnlyMode
BagOStuff$cpStash
BagOStuff$srvCache
WANObjectCache$wanCache
CriticalSectionProvider$csProvider
Returns
array
Access: internal
For use with service wiring

Definition at line 79 of file MWLBFactory.php.

References $wgCommandLineMode, MediaWiki\Config\ServiceOptions\assertRequiredOptions(), assertValidServerConfigs(), DBO_COMPRESS, DBO_SSL, MediaWiki\Config\ServiceOptions\get(), getDbTypesWithSchemas(), ConfiguredReadOnlyMode\getReason(), and initServerInfo().

◆ applyGlobalState()

static MWLBFactory::applyGlobalState ( ILBFactory  $lbFactory,
Config  $config,
IBufferingStatsdDataFactory  $stats 
)
static

Apply global state from the current web request or other PHP process.

This technically violates the principle constraint on ServiceWiring to be deterministic for a given site configuration. The exemption made here is solely to aid in debugging and influence non-nominal behaviour such as ChronologyProtector. That is, the state applied here must never change the logical destination or meaning of any database-related methods, it merely applies preferences and debugging information.

The code here must be non-essential, with LBFactory behaving the same toward its consumers regardless of whether this is applied or not.

For example, something may instantiate LBFactory for the current wiki without calling this, and its consumers must not be able to tell the difference. Likewise, in the future MediaWiki may instantiate service wiring and LBFactory for a foreign wiki in the same farm and apply the current global state to that, and that should be fine as well.

Parameters
ILBFactory$lbFactory
Config$config
IBufferingStatsdDataFactory$stats

Definition at line 369 of file MWLBFactory.php.

◆ assertValidServerConfigs()

static MWLBFactory::assertValidServerConfigs ( array  $servers,
  $ldDB,
  $ldTP 
)
staticprivate
Parameters
array$servers
string$ldDBLocal domain database name
string$ldTPLocal domain prefix

Definition at line 235 of file MWLBFactory.php.

References $type, reportIfPrefixSet(), reportMismatchedDBs(), and reportMismatchedPrefixes().

Referenced by applyDefaultConfig().

◆ getDbTypesWithSchemas()

static MWLBFactory::getDbTypesWithSchemas ( )
staticprivate
Returns
array

Definition at line 177 of file MWLBFactory.php.

Referenced by applyDefaultConfig().

◆ getLBFactoryClass()

static MWLBFactory::getLBFactoryClass ( array  $config)
static

Decide which LBFactory class to use.

Access: internal
For use by ServiceWiring
Parameters
array$config(e.g. $wgLBFactoryConf)
Returns
string Class name

Definition at line 316 of file MWLBFactory.php.

◆ initServerInfo()

static MWLBFactory::initServerInfo ( array  $server,
ServiceOptions  $options 
)
staticprivate
Parameters
array$server
ServiceOptions$options
Returns
array

Definition at line 186 of file MWLBFactory.php.

References DBO_DEBUG, DBO_DEFAULT, MediaWiki\Config\ServiceOptions\get(), and MW_ENTRY_POINT.

Referenced by applyDefaultConfig().

◆ logDeprecation()

static MWLBFactory::logDeprecation (   $msg)
static

Log a database deprecation warning.

Parameters
string$msgDeprecation message

Definition at line 450 of file MWLBFactory.php.

References wfGetCaller().

◆ reportIfPrefixSet()

static MWLBFactory::reportIfPrefixSet (   $prefix,
  $dbType 
)
staticprivate
Parameters
string$prefixTable prefix
string$dbTypeDatabase type
Returns
never

Definition at line 264 of file MWLBFactory.php.

References MWExceptionRenderer\AS_PRETTY, and MWExceptionRenderer\output().

Referenced by assertValidServerConfigs().

◆ reportMismatchedDBs()

static MWLBFactory::reportMismatchedDBs (   $srvDB,
  $ldDB 
)
staticprivate
Parameters
string$srvDBServer config database
string$ldDBLocal DB domain database
Returns
never

Definition at line 278 of file MWLBFactory.php.

References MWExceptionRenderer\AS_PRETTY, and MWExceptionRenderer\output().

Referenced by assertValidServerConfigs().

◆ reportMismatchedPrefixes()

static MWLBFactory::reportMismatchedPrefixes (   $srvTP,
  $ldTP 
)
staticprivate
Parameters
string$srvTPServer config table prefix
string$ldTPLocal DB domain database
Returns
never

Definition at line 296 of file MWLBFactory.php.

References MWExceptionRenderer\AS_PRETTY, and MWExceptionRenderer\output().

Referenced by assertValidServerConfigs().

◆ setDomainAliases()

static MWLBFactory::setDomainAliases ( ILBFactory  $lbFactory)
static
Parameters
ILBFactory$lbFactory

Definition at line 335 of file MWLBFactory.php.

References Wikimedia\Rdbms\ILBFactory\getLocalDomainID(), and Wikimedia\Rdbms\ILBFactory\setDomainAliases().

Member Data Documentation

◆ $loggedDeprecations

array MWLBFactory::$loggedDeprecations = []
staticprivate

Cache of already-logged deprecation messages.

Definition at line 42 of file MWLBFactory.php.

◆ APPLY_DEFAULT_CONFIG_OPTIONS

const MWLBFactory::APPLY_DEFAULT_CONFIG_OPTIONS
Initial value:
= [
'DBcompress',
'DBDefaultGroup',
'DBmwschema',
'DBname',
'DBpassword',
'DBport',
'DBprefix',
'DBserver',
'DBservers',
'DBssl',
'DBtype',
'DBuser',
'DebugDumpSql',
'DebugLogFile',
'DebugToolbar',
'ExternalServers',
'SQLiteDataDir',
'SQLMode',
]
Access: internal
For use by ServiceWiring

Definition at line 47 of file MWLBFactory.php.


The documentation for this class was generated from the following file: