Merge "[search] Fix method call on null value"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index 151bb06..59c3c1f 100644 (file)
@@ -167,8 +167,6 @@ class ObjectCache {
                if ( isset( $params['loggroup'] ) ) {
                        $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] );
                } else {
-                       // For backwards-compatability with custom parameters, lets not
-                       // have all logging suddenly disappear
                        $params['logger'] = LoggerFactory::getInstance( 'objectcache' );
                }
                if ( !isset( $params['keyspace'] ) ) {
@@ -178,8 +176,26 @@ class ObjectCache {
                        return call_user_func( $params['factory'], $params );
                } elseif ( isset( $params['class'] ) ) {
                        $class = $params['class'];
-                       if ( $class === 'MultiWriteBagOStuff' && !isset( $params['asyncHandler'] ) ) {
-                               $params['asyncHandler'] = 'DeferredUpdates::addCallableUpdate';
+                       // Automatically set the 'async' update handler
+                       if ( $class === 'MultiWriteBagOStuff' ) {
+                               $params['asyncHandler'] = isset( $params['asyncHandler'] )
+                                       ? $params['asyncHandler']
+                                       : 'DeferredUpdates::addCallableUpdate';
+                       }
+                       // Do b/c logic for MemcachedBagOStuff
+                       if ( is_subclass_of( $class, 'MemcachedBagOStuff' ) ) {
+                               if ( !isset( $params['servers'] ) ) {
+                                       $params['servers'] = $GLOBALS['wgMemCachedServers'];
+                               }
+                               if ( !isset( $params['debug'] ) ) {
+                                       $params['debug'] = $GLOBALS['wgMemCachedDebug'];
+                               }
+                               if ( !isset( $params['persistent'] ) ) {
+                                       $params['persistent'] = $GLOBALS['wgMemCachedPersistent'];
+                               }
+                               if ( !isset( $params['timeout'] ) ) {
+                                       $params['timeout'] = $GLOBALS['wgMemCachedTimeout'];
+                               }
                        }
                        return new $class( $params );
                } else {
@@ -256,20 +272,6 @@ class ObjectCache {
                return self::newFromId( $id );
        }
 
-       /**
-        * Factory function that creates a memcached client object.
-        *
-        * This always uses the PHP client, since the PECL client has a different
-        * hashing scheme and a different interpretation of the flags bitfield, so
-        * switching between the two clients randomly would be disastrous.
-        *
-        * @param array $params
-        * @return MemcachedPhpBagOStuff
-        */
-       public static function newMemcached( $params ) {
-               return new MemcachedPhpBagOStuff( $params );
-       }
-
        /**
         * Create a new cache object of the specified type.
         *
@@ -290,6 +292,11 @@ class ObjectCache {
                $class = $params['relayerConfig']['class'];
                $params['relayer'] = new $class( $params['relayerConfig'] );
                $params['cache'] = self::newFromId( $params['cacheId'] );
+               if ( isset( $params['loggroup'] ) ) {
+                       $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] );
+               } else {
+                       $params['logger'] = LoggerFactory::getInstance( 'objectcache' );
+               }
                $class = $params['class'];
 
                return new $class( $params );