/**
* Constructor. Parameters are:
- * - writeFactory : ObjectFactory::getObjectFromSpec parameters yeilding BagOStuff.
+ * - writeFactory : ObjectFactory::getObjectFromSpec array yeilding BagOStuff.
* This object will be used for writes (e.g. the master DB).
- * - readFactory : ObjectFactory::getObjectFromSpec parameters yeilding BagOStuff.
+ * - readFactory : ObjectFactory::getObjectFromSpec array yeilding BagOStuff.
* This object will be used for reads (e.g. a slave DB).
*
* @param array $params
/**
* $params include:
- * - caches: This should have a numbered array of cache parameter
- * structures, in the style required by $wgObjectCaches. See
- * the documentation of $wgObjectCaches for more detail.
- * BagOStuff objects can also be used as values.
+ * - caches: A numbered array of either ObjectFactory::getObjectFromSpec
+ * arrays yeilding BagOStuff objects or direct BagOStuff objects.
+ * If using the former, the 'args' field *must* be set.
* The first cache is the primary one, being the first to
* be read in the fallback chain. Writes happen to all stores
* in the order they are defined. However, lock()/unlock() calls
$this->caches = array();
foreach ( $params['caches'] as $cacheInfo ) {
- $this->caches[] = ( $cacheInfo instanceof BagOStuff )
- ? $cacheInfo
- : ObjectCache::newFromParams( $cacheInfo );
+ if ( $cacheInfo instanceof BagOStuff ) {
+ $this->caches[] = $cacheInfo;
+ } else {
+ if ( !isset( $cacheInfo['args'] ) ) {
+ // B/C for when $cacheInfo was for ObjectCache::newFromParams().
+ // Callers intenting this to be for ObjectFactory::getObjectFromSpec
+ // should have set "args" per the docs above. Doings so avoids extra
+ // (likely harmless) params (factory/class/calls) ending up in "args".
+ $cacheInfo['args'] = array( $cacheInfo );
+ }
+ $this->caches[] = ObjectFactory::getObjectFromSpec( $cacheInfo );
+ }
}
$this->asyncWrites = isset( $params['replication'] ) && $params['replication'] === 'async';