From: Timo Tijhof Date: Mon, 24 Aug 2015 20:53:16 +0000 (+0200) Subject: objectcache: Use newAccelerator() fallback instead of try/catch X-Git-Tag: 1.31.0-rc.0~10286^2 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=f1223f90fd4b3891bcd18fe621e998c4190c8b9b;p=lhc%2Fweb%2Fwiklou.git objectcache: Use newAccelerator() fallback instead of try/catch Also remove confusing use of $wgMemc in LoadMonitorMySQL which should always be the same as wfGetMainCache(). Change-Id: I4fb9d075a37d3d45af71a5026ccf2eb17f24d7b0 --- diff --git a/includes/db/LoadMonitorMySQL.php b/includes/db/LoadMonitorMySQL.php index 752d009171..30084190b5 100644 --- a/includes/db/LoadMonitorMySQL.php +++ b/includes/db/LoadMonitorMySQL.php @@ -34,12 +34,10 @@ class LoadMonitorMySQL implements LoadMonitor { protected $mainCache; public function __construct( $parent ) { - global $wgMemc; - $this->parent = $parent; $this->srvCache = ObjectCache::newAccelerator( 'hash' ); - $this->mainCache = $wgMemc ?: wfGetMainCache(); + $this->mainCache = wfGetMainCache(); } public function scaleLoads( &$loads, $group = false, $wiki = false ) { diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index b49c4c59be..e0a08b2fe5 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -138,13 +138,12 @@ class SwiftFileBackend extends FileBackendStore { if ( PHP_SAPI === 'cli' ) { $this->srvCache = wfGetMainCache(); // preferrably memcached } else { - try { // look for APC, XCache, WinCache, ect... - $this->srvCache = ObjectCache::newAccelerator(); - } catch ( Exception $e ) { - } + // look for APC, XCache, WinCache, ect... + $this->srvCache = ObjectCache::newAccelerator( CACHE_NONE ); } + } else { + $this->srvCache = new EmptyBagOStuff(); } - $this->srvCache = $this->srvCache ?: new EmptyBagOStuff(); } public function getFeatures() { diff --git a/includes/utils/MWCryptHKDF.php b/includes/utils/MWCryptHKDF.php index 1ddd119511..740df92241 100644 --- a/includes/utils/MWCryptHKDF.php +++ b/includes/utils/MWCryptHKDF.php @@ -161,7 +161,7 @@ class MWCryptHKDF { * @throws MWException */ protected static function singleton() { - global $wgHKDFAlgorithm, $wgHKDFSecret, $wgSecretKey; + global $wgHKDFAlgorithm, $wgHKDFSecret, $wgSecretKey, $wgMainCacheType; $secret = $wgHKDFSecret ?: $wgSecretKey; if ( !$secret ) { @@ -176,11 +176,7 @@ class MWCryptHKDF { $context[] = gethostname(); // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup - try { - $cache = ObjectCache::newAccelerator(); - } catch ( Exception $e ) { - $cache = wfGetMainCache(); - } + $cache = ObjectCache::newAccelerator( $wgMainCacheType ); if ( is_null( self::$singleton ) ) { self::$singleton = new self( $secret, $wgHKDFAlgorithm, $cache, $context );