Merge "Change "slave" => "replica DB" in /includes"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index e1bb2db..9ff39a0 100644 (file)
@@ -65,7 +65,7 @@ use MediaWiki\Services\ServiceDisabledException;
  *   Purpose: Ephemeral global storage.
  *   Stored centrally within the primary data-center.
  *   Changes are applied there first and replicated to other DCs (best-effort).
- *   To retrieve the latest value (e.g. not from a slave), use BagOStuff::READ_LATEST.
+ *   To retrieve the latest value (e.g. not from a replica DB), use BagOStuff::READ_LATEST.
  *   This store may be subject to LRU style evictions.
  *
  * - ObjectCache::getInstance( $cacheType )
@@ -228,14 +228,12 @@ class ObjectCache {
                        }
                }
 
-               try {
-                       // Make sure we actually have a DB backend before falling back to CACHE_DB
-                       MediaWikiServices::getInstance()->getDBLoadBalancer();
-                       $candidate = CACHE_DB;
-               } catch ( ServiceDisabledException $e ) {
+               if ( MediaWikiServices::getInstance()->isServiceDisabled( 'DBLoadBalancer' ) ) {
                        // The LoadBalancer is disabled, probably because
                        // MediaWikiServices::disableStorageBackend was called.
                        $candidate = CACHE_NONE;
+               } else {
+                       $candidate = CACHE_DB;
                }
 
                return self::getInstance( $candidate );
@@ -251,7 +249,7 @@ class ObjectCache {
         *     ObjectCache::getLocalServerInstance( $fallbackType );
         *
         *     // From $wgObjectCaches via newFromParams()
-        *     ObjectCache::getLocalServerInstance( array( 'fallback' => $fallbackType ) );
+        *     ObjectCache::getLocalServerInstance( [ 'fallback' => $fallbackType ] );
         *
         * @param int|string|array $fallback Fallback cache or parameter map with 'fallback'
         * @return BagOStuff
@@ -280,7 +278,7 @@ class ObjectCache {
         * @param array $params [optional] Array key 'fallback' for $fallback.
         * @param int|string $fallback Fallback cache, e.g. (CACHE_NONE, "hash") (since 1.24)
         * @return BagOStuff
-        * @deprecated 1.27
+        * @deprecated since 1.27
         */
        public static function newAccelerator( $params = [], $fallback = null ) {
                if ( $fallback === null ) {