Clean up array() syntax in docs, part II
[lhc/web/wiklou.git] / includes / db / loadbalancer / LoadBalancer.php
index dbf031e..1269c3e 100644 (file)
@@ -138,8 +138,20 @@ class LoadBalancer {
                        }
                }
 
-               $this->srvCache = ObjectCache::getLocalServerInstance();
-               $this->wanCache = ObjectCache::getMainWANInstance();
+               // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
+               // @TODO: inject these in via LBFactory at some point
+               $cache = ObjectCache::getLocalServerInstance();
+               if ( $cache->getQoS( $cache::ATTR_EMULATION ) > $cache::QOS_EMULATION_SQL ) {
+                       $this->srvCache = $cache;
+               } else {
+                       $this->srvCache = new EmptyBagOStuff();
+               }
+               $wCache = ObjectCache::getMainWANInstance();
+               if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
+                       $this->wanCache = $wCache;
+               } else {
+                       $this->wanCache = WANObjectCache::newEmpty();
+               }
 
                if ( isset( $params['trxProfiler'] ) ) {
                        $this->trxProfiler = $params['trxProfiler'];
@@ -605,7 +617,7 @@ class LoadBalancer {
                        /**
                         * This can happen in code like:
                         *   foreach ( $dbs as $db ) {
-                        *     $conn = $lb->getConnection( DB_SLAVE, array(), $db );
+                        *     $conn = $lb->getConnection( DB_SLAVE, [], $db );
                         *     ...
                         *     $lb->reuseConnection( $conn );
                         *   }