/**
* @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 ( isset( $lbConf['servers'] ) ) {
// Server array is already explicitly configured; leave alone
// Work around the reserved word usage in MediaWiki schema
'keywordTableMap' => [ 'user' => 'mwuser', 'text' => 'pagecontent' ]
];
+ } elseif ( $server['type'] === 'mssql' ) {
+ $server += [
+ 'port' => $mainConfig->get( 'DBport' ),
+ 'useWindowsAuth' => $mainConfig->get( 'DBWindowsAuthentication' )
+ ];
}
+
if ( in_array( $server['type'], $typesWithSchema, true ) ) {
$server += [ 'schema' => $mainConfig->get( 'DBmwschema' ) ];
}
$server['port'] = $mainConfig->get( 'DBport' );
// Work around the reserved word usage in MediaWiki schema
$server['keywordTableMap'] = [ 'user' => 'mwuser', 'text' => 'pagecontent' ];
+ } elseif ( $server['type'] === 'mssql' ) {
+ $server['port'] = $mainConfig->get( 'DBport' );
+ $server['useWindowsAuth'] = $mainConfig->get( 'DBWindowsAuthentication' );
}
$lbConf['servers'] = [ $server ];
}