44 static $typesWithSchema = [
'postgres',
'msssql' ];
48 $mainConfig->get(
'DBname' ),
50 $mainConfig->get(
'DBprefix' )
52 'profiler' => Profiler::instance(),
53 'trxProfiler' => Profiler::instance()->getTransactionProfiler(),
54 'replLogger' => LoggerFactory::getInstance(
'DBReplication' ),
55 'queryLogger' => LoggerFactory::getInstance(
'DBQuery' ),
56 'connLogger' => LoggerFactory::getInstance(
'DBConnection' ),
57 'perfLogger' => LoggerFactory::getInstance(
'DBPerformance' ),
58 'errorLogger' => [ MWExceptionHandler::class,
'logException' ],
61 'readOnlyReason' => $readOnlyMode->
getReason(),
67 if ( $lbConf[
'class'] ===
'LBFactorySimple' ) {
68 if ( isset( $lbConf[
'servers'] ) ) {
70 } elseif ( is_array( $mainConfig->get(
'DBservers' ) ) ) {
71 foreach ( $mainConfig->get(
'DBservers' ) as $i => $server ) {
72 if ( $server[
'type'] ===
'sqlite' ) {
73 $server += [
'dbDirectory' => $mainConfig->get(
'SQLiteDataDir' ) ];
74 } elseif ( $server[
'type'] ===
'postgres' ) {
76 'port' => $mainConfig->get(
'DBport' ),
78 'keywordTableMap' => [
'user' =>
'mwuser',
'text' =>
'pagecontent' ]
80 } elseif ( $server[
'type'] ===
'mssql' ) {
82 'port' => $mainConfig->get(
'DBport' ),
83 'useWindowsAuth' => $mainConfig->get(
'DBWindowsAuthentication' )
87 if ( in_array( $server[
'type'], $typesWithSchema,
true ) ) {
88 $server += [
'schema' => $mainConfig->get(
'DBmwschema' ) ];
92 'tablePrefix' => $mainConfig->get(
'DBprefix' ),
94 'sqlMode' => $mainConfig->get(
'SQLMode' ),
95 'utf8Mode' => $mainConfig->get(
'DBmysql5' )
98 $lbConf[
'servers'][$i] = $server;
106 'host' => $mainConfig->get(
'DBserver' ),
107 'user' => $mainConfig->get(
'DBuser' ),
108 'password' => $mainConfig->get(
'DBpassword' ),
109 'dbname' => $mainConfig->get(
'DBname' ),
110 'tablePrefix' => $mainConfig->get(
'DBprefix' ),
111 'type' => $mainConfig->get(
'DBtype' ),
114 'sqlMode' => $mainConfig->get(
'SQLMode' ),
115 'utf8Mode' => $mainConfig->get(
'DBmysql5' )
117 if ( in_array( $server[
'type'], $typesWithSchema,
true ) ) {
118 $server += [
'schema' => $mainConfig->get(
'DBmwschema' ) ];
120 if ( $server[
'type'] ===
'sqlite' ) {
121 $server[
'dbDirectory'] = $mainConfig->get(
'SQLiteDataDir' );
122 } elseif ( $server[
'type'] ===
'postgres' ) {
123 $server[
'port'] = $mainConfig->get(
'DBport' );
125 $server[
'keywordTableMap'] = [
'user' =>
'mwuser',
'text' =>
'pagecontent' ];
126 } elseif ( $server[
'type'] ===
'mssql' ) {
127 $server[
'port'] = $mainConfig->get(
'DBport' );
128 $server[
'useWindowsAuth'] = $mainConfig->get(
'DBWindowsAuthentication' );
130 $lbConf[
'servers'] = [ $server ];
132 if ( !isset( $lbConf[
'externalClusters'] ) ) {
133 $lbConf[
'externalClusters'] = $mainConfig->get(
'ExternalServers' );
135 } elseif ( $lbConf[
'class'] ===
'LBFactoryMulti' ) {
136 if ( isset( $lbConf[
'serverTemplate'] ) ) {
137 if ( in_array( $lbConf[
'serverTemplate'][
'type'], $typesWithSchema,
true ) ) {
138 $lbConf[
'serverTemplate'][
'schema'] = $mainConfig->get(
'DBmwschema' );
140 $lbConf[
'serverTemplate'][
'sqlMode'] = $mainConfig->get(
'SQLMode' );
141 $lbConf[
'serverTemplate'][
'utf8Mode'] = $mainConfig->get(
'DBmysql5' );
146 $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
147 if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
148 $lbConf[
'srvCache'] = $sCache;
150 $cCache = ObjectCache::getLocalClusterInstance();
151 if ( $cCache->getQoS( $cCache::ATTR_EMULATION ) > $cCache::QOS_EMULATION_SQL ) {
152 $lbConf[
'memStash'] = $cCache;
154 $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
155 if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
156 $lbConf[
'wanCache'] = $wCache;
174 'LBFactory_Simple' =>
'LBFactorySimple',
175 'LBFactory_Single' =>
'LBFactorySingle',
176 'LBFactory_Multi' =>
'LBFactoryMulti'
179 $class = $config[
'class'];
181 if ( isset( $bcClasses[$class] ) ) {
182 $class = $bcClasses[$class];
184 '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details',
191 'LBFactorySingle' => Wikimedia\Rdbms\LBFactorySingle::class,
192 'LBFactorySimple' => Wikimedia\Rdbms\LBFactorySimple::class,
193 'LBFactoryMulti' => Wikimedia\Rdbms\LBFactoryMulti::class
196 if ( isset( $compat[$class] ) ) {
197 $class = $compat[$class];