Merge "Add 3D filetype for STL files"
[lhc/web/wiklou.git] / includes / db / MWLBFactory.php
index 09d8fab..464a918 100644 (file)
@@ -33,9 +33,12 @@ abstract class MWLBFactory {
        /**
         * @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' ];
@@ -55,10 +58,12 @@ abstract class MWLBFactory {
                        '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
@@ -72,7 +77,13 @@ abstract class MWLBFactory {
                                                        // 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' ) ];
                                        }
@@ -112,6 +123,9 @@ abstract class MWLBFactory {
                                        $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 ];
                        }