/**
* @param array $lbConf Config for LBFactory::__construct()
* @param Config $mainConfig Main config object from MediaWikiServices
+ * @param ConfiguredReadOnlyMode $readOnlyMode
* @return array
*/
- public static function applyDefaultConfig( array $lbConf, Config $mainConfig ) {
+ public static function applyDefaultConfig( array $lbConf, Config $mainConfig,
+ ConfiguredReadOnlyMode $readOnlyMode
+ ) {
global $wgCommandLineMode;
static $typesWithSchema = [ 'postgres', 'msssql' ];
'errorLogger' => [ MWExceptionHandler::class, 'logException' ],
'cliMode' => $wgCommandLineMode,
'hostname' => wfHostname(),
- // TODO: replace the global wfConfiguredReadOnlyReason() with a service.
- 'readOnlyReason' => wfConfiguredReadOnlyReason(),
+ 'readOnlyReason' => $readOnlyMode->getReason(),
];
// When making changes here, remember to also specify MediaWiki-specific options
// for Database classes in the relevant Installer subclass.
// Such as MysqlInstaller::openConnection and PostgresInstaller::openConnectionWithParams.
- if ( $lbConf['class'] === 'LBFactorySimple' ) {
+ if ( $lbConf['class'] === Wikimedia\Rdbms\LBFactorySimple::class ) {
if ( isset( $lbConf['servers'] ) ) {
// Server array is already explicitly configured; leave alone
} elseif ( is_array( $mainConfig->get( 'DBservers' ) ) ) {
if ( !isset( $lbConf['externalClusters'] ) ) {
$lbConf['externalClusters'] = $mainConfig->get( 'ExternalServers' );
}
- } elseif ( $lbConf['class'] === 'LBFactoryMulti' ) {
+ } elseif ( $lbConf['class'] === Wikimedia\Rdbms\LBFactoryMulti::class ) {
if ( isset( $lbConf['serverTemplate'] ) ) {
if ( in_array( $lbConf['serverTemplate']['type'], $typesWithSchema, true ) ) {
$lbConf['serverTemplate']['schema'] = $mainConfig->get( 'DBmwschema' );
}
}
+ $services = MediaWikiServices::getInstance();
+
// Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
- $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
+ $sCache = $services->getLocalServerObjectCache();
if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
$lbConf['srvCache'] = $sCache;
}
- $cCache = ObjectCache::getLocalClusterInstance();
- if ( $cCache->getQoS( $cCache::ATTR_EMULATION ) > $cCache::QOS_EMULATION_SQL ) {
- $lbConf['memCache'] = $cCache;
+ $mStash = $services->getMainObjectStash();
+ if ( $mStash->getQoS( $mStash::ATTR_EMULATION ) > $mStash::QOS_EMULATION_SQL ) {
+ $lbConf['memStash'] = $mStash;
}
- $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $wCache = $services->getMainWANObjectCache();
if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
$lbConf['wanCache'] = $wCache;
}