Merge "mw.rcfilters.ui.SaveFiltersPopupButtonWidget: Remove pointless option"
[lhc/web/wiklou.git] / includes / db / MWLBFactory.php
index fe063f2..aa1918d 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,8 +58,7 @@ 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
@@ -140,16 +142,18 @@ abstract class MWLBFactory {
                        }
                }
 
+               $services = MediaWikiServices::getInstance();
+
                // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
-               $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
+               $sCache = $services->getLocalServerObjectCache();
                if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
                        $lbConf['srvCache'] = $sCache;
                }
-               $cCache = ObjectCache::getLocalClusterInstance();
-               if ( $cCache->getQoS( $cCache::ATTR_EMULATION ) > $cCache::QOS_EMULATION_SQL ) {
-                       $lbConf['memCache'] = $cCache;
+               $mStash = $services->getMainObjectStash();
+               if ( $mStash->getQoS( $mStash::ATTR_EMULATION ) > $mStash::QOS_EMULATION_SQL ) {
+                       $lbConf['memStash'] = $mStash;
                }
-               $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+               $wCache = $services->getMainWANObjectCache();
                if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
                        $lbConf['wanCache'] = $wCache;
                }