Merge "[search] Fix method call on null value"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index 56b5cbd..59c3c1f 100644 (file)
@@ -176,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 {
@@ -254,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.
         *