From: Aaron Date: Thu, 20 Sep 2012 19:24:14 +0000 (-0700) Subject: [FileBackend] Fallback to $wgMemc for swift auth caching in cli mode. X-Git-Tag: 1.31.0-rc.0~22323 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=c5e336c9adfae898c7224e3180e4e3c59108f14d;p=lhc%2Fweb%2Fwiklou.git [FileBackend] Fallback to $wgMemc for swift auth caching in cli mode. Change-Id: I4338c68a18f1424b0d0ec4fe3fcf77c79ba774c8 --- diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index abe834ac76..185a557ff7 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -81,7 +81,8 @@ class SwiftFileBackend extends FileBackendStore { * - levels : the number of hash levels (and digits) * - repeat : hash subdirectories are prefixed with all the * parent hash directory names (e.g. "a/ab/abc") - * - cacheAuthInfo : Whether to cache authentication tokens in APC/XCache. + * - cacheAuthInfo : Whether to cache authentication tokens in APC, XCache, ect. + * If those are not available, then the main cache will be used. * This is probably insecure in shared hosting environments. */ public function __construct( array $config ) { @@ -121,9 +122,13 @@ class SwiftFileBackend extends FileBackendStore { $this->connContainerCache = new ProcessCacheLRU( 300 ); // Cache auth token information to avoid RTTs if ( !empty( $config['cacheAuthInfo'] ) ) { - try { // look for APC, XCache, WinCache, ect... - $this->srvCache = ObjectCache::newAccelerator( array() ); - } catch ( Exception $e ) {} + if ( php_sapi_name() === 'cli' ) { + $this->srvCache = wfGetMainCache(); // preferrably memcached + } else { + try { // look for APC, XCache, WinCache, ect... + $this->srvCache = ObjectCache::newAccelerator( array() ); + } catch ( Exception $e ) {} + } } $this->srvCache = $this->srvCache ? $this->srvCache : new EmptyBagOStuff(); }