From da391b8932fb22eb6dab20e47a1b5f9fd4e6afe5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Jul 2014 11:03:10 +0200 Subject: [PATCH 1/3] InstanceId is properly injected into factory. Remove comment. --- lib/base.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index afa498e502..be0955090e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -478,8 +478,6 @@ class OC { self::initPaths(); if (OC_Config::getValue('instanceid', false)) { - // \OC\Memcache\Cache has a hidden dependency on - // OC_Util::getInstanceId() for namespacing. See #5409. try { self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader')); } catch (\Exception $ex) { From 9be8ac5867e23663467068bed9532ca84788f073 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Jul 2014 11:14:36 +0200 Subject: [PATCH 2/3] Memcache\Factory: Remove static, use globalPrefix. --- lib/base.php | 13 +++++++++++-- lib/private/memcache/factory.php | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/base.php b/lib/base.php index be0955090e..e856574942 100644 --- a/lib/base.php +++ b/lib/base.php @@ -477,9 +477,18 @@ class OC { self::handleAuthHeaders(); self::initPaths(); - if (OC_Config::getValue('instanceid', false)) { + + // The class loader takes an optional low-latency cache, which MUST be + // namespaced. The instanceid is used for namespacing, but might be + // unavailable at this point. Futhermore, it might not be possible to + // generate an instanceid via \OC_Util::getInstanceId() because the + // config file may not be writable. As such, we only register a class + // loader cache if instanceid is available without trying to create one. + $instanceId = OC_Config::getValue('instanceid', null); + if ($instanceId) { try { - self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader')); + $memcacheFactory = new \OC\Memcache\Factory($instanceId); + self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader')); } catch (\Exception $ex) { } } diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index d60b157efe..8e47a8899f 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -59,7 +59,8 @@ class Factory implements ICacheFactory { * @param string $prefix * @return null|Cache */ - public static function createLowLatency($prefix = '') { + public function createLowLatency($prefix = '') { + $prefix = $this->globalPrefix . '/' . $prefix; if (XCache::isAvailable()) { return new XCache($prefix); } elseif (APCu::isAvailable()) { @@ -76,7 +77,7 @@ class Factory implements ICacheFactory { * * @return bool */ - public static function isAvailableLowLatency() { + public function isAvailableLowLatency() { return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable(); } From a8fbc709ce141257df1c1edf3eac3bb154db29a5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Jul 2014 11:18:40 +0200 Subject: [PATCH 3/3] Add registerAutoloaderCache(). --- lib/base.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/base.php b/lib/base.php index e856574942..6751f897df 100644 --- a/lib/base.php +++ b/lib/base.php @@ -475,23 +475,9 @@ class OC { @ini_set('file_uploads', '50'); self::handleAuthHeaders(); - self::initPaths(); + self::registerAutoloaderCache(); - // The class loader takes an optional low-latency cache, which MUST be - // namespaced. The instanceid is used for namespacing, but might be - // unavailable at this point. Futhermore, it might not be possible to - // generate an instanceid via \OC_Util::getInstanceId() because the - // config file may not be writable. As such, we only register a class - // loader cache if instanceid is available without trying to create one. - $instanceId = OC_Config::getValue('instanceid', null); - if ($instanceId) { - try { - $memcacheFactory = new \OC\Memcache\Factory($instanceId); - self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader')); - } catch (\Exception $ex) { - } - } OC_Util::isSetLocaleWorking(); // setup 3rdparty autoloader @@ -651,6 +637,23 @@ class OC { } } + protected static function registerAutoloaderCache() { + // The class loader takes an optional low-latency cache, which MUST be + // namespaced. The instanceid is used for namespacing, but might be + // unavailable at this point. Futhermore, it might not be possible to + // generate an instanceid via \OC_Util::getInstanceId() because the + // config file may not be writable. As such, we only register a class + // loader cache if instanceid is available without trying to create one. + $instanceId = OC_Config::getValue('instanceid', null); + if ($instanceId) { + try { + $memcacheFactory = new \OC\Memcache\Factory($instanceId); + self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader')); + } catch (\Exception $ex) { + } + } + } + /** * Handle the request */