* @ingroup Database
*/
abstract class LBFactoryMW extends LBFactory {
- /** @noinspection PhpMissingParentConstructorInspection */
/**
* Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
* @param array $conf
* @TODO: inject objects via dependency framework
*/
public static function applyDefaultConfig( array $conf ) {
- global $wgCommandLineMode, $wgSQLMode, $wgDBmysql5, $wgDBname, $wgDBprefix;
+ global $wgDBtype, $wgSQLMode, $wgDBmysql5, $wgDBname, $wgDBprefix, $wgDBmwschema;
+ global $wgCommandLineMode;
$defaults = [
'localDomain' => new DatabaseDomain( $wgDBname, null, $wgDBprefix ),
$defaults['wanCache'] = $wCache;
}
+ // Determine schema defaults. Currently Microsoft SQL Server uses $wgDBmwschema,
+ // and everything else doesn't use a schema (e.g. null)
+ // Although postgres and oracle support schemas, we don't use them (yet)
+ // to maintain backwards compatibility
+ $schema = ( $wgDBtype === 'mssql' ) ? $wgDBmwschema : null;
+
if ( isset( $conf['serverTemplate'] ) ) { // LBFactoryMulti
+ $conf['serverTemplate']['schema'] = $schema;
$conf['serverTemplate']['sqlMode'] = $wgSQLMode;
$conf['serverTemplate']['utf8Mode'] = $wgDBmysql5;
+ } elseif ( isset( $conf['servers'] ) ) { // LBFactorySimple
+ foreach ( $conf['servers'] as $i => $server ) {
+ $conf['servers'][$i]['schema'] = $schema;
+ }
}
return $conf + $defaults;
" no viable database extension found for type '$dbType'" );
}
- // Determine schema defaults. Currently Microsoft SQL Server uses $wgDBmwschema,
- // and everything else doesn't use a schema (e.g. null)
- // Although postgres and oracle support schemas, we don't use them (yet)
- // to maintain backwards compatibility
- $defaultSchemas = [
- 'mssql' => 'get from global',
- ];
-
$class = 'Database' . ucfirst( $driver );
if ( class_exists( $class ) && is_subclass_of( $class, 'IDatabase' ) ) {
// Resolve some defaults for b/c
$p['flags'] = isset( $p['flags'] ) ? $p['flags'] : 0;
$p['variables'] = isset( $p['variables'] ) ? $p['variables'] : [];
$p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : '';
- if ( !isset( $p['schema'] ) ) {
- $p['schema'] = isset( $defaultSchemas[$dbType] ) ? $defaultSchemas[$dbType] : '';
- }
+ $p['schema'] = isset( $p['schema'] ) ? $p['schema'] : '';
$p['foreign'] = isset( $p['foreign'] ) ? $p['foreign'] : false;
$conn = new $class( $p );