diff options
author | Robin Appelman <robin@icewind.nl> | 2024-08-20 16:46:49 +0200 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2024-08-28 10:18:52 +0200 |
commit | c58bdbf378a6c2abc6b9f33dae175de762f33d8a (patch) | |
tree | 11475757594cd974535ac6d9ea0c77193143166d /lib/private/Server.php | |
parent | 114db0558c7093b6a07707035c6a62c9a8bec220 (diff) | |
download | nextcloud-server-c58bdbf378a6c2abc6b9f33dae175de762f33d8a.tar.gz nextcloud-server-c58bdbf378a6c2abc6b9f33dae175de762f33d8a.zip |
fix: delay calculating global cache prefix untill a cache is created
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Server.php')
-rw-r--r-- | lib/private/Server.php | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php index 9b2a313a257..09d1f341ce5 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -637,7 +637,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(Factory::class, function (Server $c) { $profiler = $c->get(IProfiler::class); - $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class), + $arrayCacheFactory = new \OC\Memcache\Factory(fn () => '', $c->get(LoggerInterface::class), $profiler, ArrayCache::class, ArrayCache::class, @@ -647,33 +647,40 @@ class Server extends ServerContainer implements IServerContainer { $config = $c->get(SystemConfig::class); if ($config->getValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { - if (!$config->getValue('log_query')) { - try { - $v = \OC_App::getAppVersions(); - } catch (\Doctrine\DBAL\Exception $e) { - // Database service probably unavailable - // Probably related to https://github.com/nextcloud/server/issues/37424 - return $arrayCacheFactory; + $logQuery = $config->getValue('log_query'); + $prefixClosure = function () use ($logQuery) { + if (!$logQuery) { + try { + $v = \OC_App::getAppVersions(); + } catch (\Doctrine\DBAL\Exception $e) { + // Database service probably unavailable + // Probably related to https://github.com/nextcloud/server/issues/37424 + return null; + } + } else { + // If the log_query is enabled, we can not get the app versions + // as that does a query, which will be logged and the logging + // depends on redis and here we are back again in the same function. + $v = [ + 'log_query' => 'enabled', + ]; } - } else { - // If the log_query is enabled, we can not get the app versions - // as that does a query, which will be logged and the logging - // depends on redis and here we are back again in the same function. - $v = [ - 'log_query' => 'enabled', - ]; - } - $v['core'] = implode(',', \OC_Util::getVersion()); - $version = implode(',', $v); - $instanceId = \OC_Util::getInstanceId(); - $path = \OC::$SERVERROOT; - $prefix = md5($instanceId . '-' . $version . '-' . $path); - return new \OC\Memcache\Factory($prefix, + $v['core'] = implode(',', \OC_Util::getVersion()); + $version = implode(',', $v); + $instanceId = \OC_Util::getInstanceId(); + $path = \OC::$SERVERROOT; + return md5($instanceId . '-' . $version . '-' . $path); + }; + return new \OC\Memcache\Factory($prefixClosure, $c->get(LoggerInterface::class), $profiler, + /** @psalm-taint-escape callable */ $config->getValue('memcache.local', null), + /** @psalm-taint-escape callable */ $config->getValue('memcache.distributed', null), + /** @psalm-taint-escape callable */ $config->getValue('memcache.locking', null), + /** @psalm-taint-escape callable */ $config->getValue('redis_log_file') ); } |