From f1223f90fd4b3891bcd18fe621e998c4190c8b9b Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 24 Aug 2015 22:53:16 +0200 Subject: [PATCH] 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 --- includes/db/LoadMonitorMySQL.php | 4 +--- includes/filebackend/SwiftFileBackend.php | 9 ++++----- includes/utils/MWCryptHKDF.php | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-) 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 ); -- 2.20.1