Merge "Return null from EditPage::importContentFormData"
[lhc/web/wiklou.git] / includes / db / MWLBFactory.php
index 5b62984..1803009 100644 (file)
@@ -66,16 +66,17 @@ abstract class MWLBFactory {
         * @param array $lbConf Config for LBFactory::__construct()
         * @param ServiceOptions $options
         * @param ConfiguredReadOnlyMode $readOnlyMode
-        * @param BagOStuff $srvCace
+        * @param BagOStuff $srvCache
         * @param BagOStuff $mainStash
         * @param WANObjectCache $wanCache
         * @return array
+        * @internal For use with service wiring
         */
        public static function applyDefaultConfig(
                array $lbConf,
                ServiceOptions $options,
                ConfiguredReadOnlyMode $readOnlyMode,
-               BagOStuff $srvCace,
+               BagOStuff $srvCache,
                BagOStuff $mainStash,
                WANObjectCache $wanCache
        ) {
@@ -152,10 +153,13 @@ abstract class MWLBFactory {
                        $serversCheck = [ $lbConf['serverTemplate'] ] ?? [];
                }
 
-               self::assertValidServerConfigs( $serversCheck, $options->get( 'DBname' ),
-                       $options->get( 'DBprefix' ) );
+               self::assertValidServerConfigs(
+                       $serversCheck,
+                       $options->get( 'DBname' ),
+                       $options->get( 'DBprefix' )
+               );
 
-               $lbConf = self::injectObjectCaches( $lbConf, $srvCace, $mainStash, $wanCache );
+               $lbConf = self::injectObjectCaches( $lbConf, $srvCache, $mainStash, $wanCache );
 
                return $lbConf;
        }
@@ -164,7 +168,7 @@ abstract class MWLBFactory {
         * @return array
         */
        private static function getDbTypesWithSchemas() {
-               return [ 'postgres', 'msssql' ];
+               return [ 'postgres' ];
        }
 
        /**
@@ -189,16 +193,6 @@ abstract class MWLBFactory {
                                // Work around the reserved word usage in MediaWiki schema
                                'keywordTableMap' => [ 'user' => 'mwuser', 'text' => 'pagecontent' ]
                        ];
-               } elseif ( $server['type'] === 'oracle' ) {
-                       $server += [
-                               // Work around the reserved word usage in MediaWiki schema
-                               'keywordTableMap' => [ 'user' => 'mwuser', 'text' => 'pagecontent' ]
-                       ];
-               } elseif ( $server['type'] === 'mssql' ) {
-                       $server += [
-                               'port' => $options->get( 'DBport' ),
-                               'useWindowsAuth' => $options->get( 'DBWindowsAuthentication' )
-                       ];
                }
 
                if ( in_array( $server['type'], self::getDbTypesWithSchemas(), true ) ) {
@@ -208,9 +202,6 @@ abstract class MWLBFactory {
                $flags = DBO_DEFAULT;
                $flags |= $options->get( 'DebugDumpSql' ) ? DBO_DEBUG : 0;
                $flags |= $options->get( 'DebugLogFile' ) ? DBO_DEBUG : 0;
-               if ( $server['type'] === 'oracle' ) {
-                       $flags |= $options->get( 'DBOracleDRCP' ) ? DBO_PERSISTENT : 0;
-               }
 
                $server += [
                        'tablePrefix' => $options->get( 'DBprefix' ),
@@ -231,6 +222,11 @@ abstract class MWLBFactory {
        private static function injectObjectCaches(
                array $lbConf, BagOStuff $sCache, BagOStuff $mStash, WANObjectCache $wCache
        ) {
+               // Fallback if APC style caching is not an option
+               if ( $sCache instanceof EmptyBagOStuff ) {
+                       $sCache = new HashBagOStuff( [ 'maxKeys' => 100 ] );
+               }
+
                // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
                if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
                        $lbConf['srvCache'] = $sCache;
@@ -247,8 +243,8 @@ abstract class MWLBFactory {
 
        /**
         * @param array $servers
-        * @param string $lbDB Local domain database name
-        * @param string $lbTP Local domain prefix
+        * @param string $ldDB Local domain database name
+        * @param string $ldTP Local domain prefix
         */
        private static function assertValidServerConfigs( array $servers, $ldDB, $ldTP ) {
                foreach ( $servers as $server ) {
@@ -328,6 +324,7 @@ abstract class MWLBFactory {
         *
         * @param array $config (e.g. $wgLBFactoryConf)
         * @return string Class name
+        * @internal For use with service wiring
         */
        public static function getLBFactoryClass( array $config ) {
                // For configuration backward compatibility after removing
@@ -365,13 +362,9 @@ abstract class MWLBFactory {
        /**
         * @param LBFactory $lbFactory
         * @param string $dbType 'mysql', 'sqlite', etc.
+        * @internal For use with service wiring
         */
        public static function setSchemaAliases( LBFactory $lbFactory, $dbType ) {
-               if ( $dbType instanceof Config ) {
-                       // Before 1.34 this took a whole Config just to get $dbType
-                       wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
-                       $dbType = $dbType->get( 'DBtype' );
-               }
                if ( $dbType === 'mysql' ) {
                        /**
                         * When SQLite indexes were introduced in r45764, it was noted that
@@ -398,6 +391,7 @@ abstract class MWLBFactory {
        /**
         * Log a database deprecation warning
         * @param string $msg Deprecation message
+        * @internal For use with service wiring
         */
        public static function logDeprecation( $msg ) {
                global $wgDevelopmentWarnings;