From bc6f7af091debecb1fcd713526642dc7d5e64e57 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 20 Apr 2023 23:10:34 +0200 Subject: [PATCH 1/2] add the server roots and version info hash to apcu prefix fixes collissions when more than one instance is running on the same system For the memcaches we use a more complex prefix, where version and instance ID are incorporated. We do not have this data at hand at this point of time. But we can get the mtime of the version.php file relatively cheap. Signed-off-by: Arthur Schiwon --- lib/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index 8b95437cb23..6d46396552d 100644 --- a/lib/base.php +++ b/lib/base.php @@ -598,7 +598,7 @@ class OC { // Add default composer PSR-4 autoloader self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; - self::$composerAutoloader->setApcuPrefix('composer_autoload'); + self::$composerAutoloader->setApcuPrefix('composer_autoload_' . md5(OC::$SERVERROOT . '_' . filemtime(OC::$SERVERROOT . '/version.php'))); try { self::initPaths(); From 2408b71aa9240a2d5deb649ab818a1e99219a89b Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 21 Apr 2023 11:28:01 +0200 Subject: [PATCH 2/2] Read mtime of version.php only once - in most cases it would read again in \OC_Util::loadVersion anyway - remove some unused use statements Signed-off-by: Arthur Schiwon --- lib/base.php | 6 ++++-- lib/private/legacy/OC_Util.php | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/base.php b/lib/base.php index 6d46396552d..32ac60c8c4f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -68,7 +68,6 @@ declare(strict_types=1); use OC\Encryption\HookManager; use OC\EventDispatcher\SymfonyAdapter; -use OC\Files\Filesystem; use OC\Share20\Hooks; use OCP\EventDispatcher\IEventDispatcher; use OCP\Group\Events\UserRemovedEvent; @@ -115,6 +114,8 @@ class OC { public static string $configDir; + public static int $VERSION_MTIME = 0; + /** * requested app */ @@ -598,7 +599,8 @@ class OC { // Add default composer PSR-4 autoloader self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; - self::$composerAutoloader->setApcuPrefix('composer_autoload_' . md5(OC::$SERVERROOT . '_' . filemtime(OC::$SERVERROOT . '/version.php'))); + OC::$VERSION_MTIME = filemtime(OC::$SERVERROOT . '/version.php'); + self::$composerAutoloader->setApcuPrefix('composer_autoload_' . md5(OC::$SERVERROOT . '_' . OC::$VERSION_MTIME)); try { self::initPaths(); diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 7f06900feb0..833fb994ec4 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -65,7 +65,6 @@ */ use bantu\IniGetWrapper\IniGetWrapper; -use OC\AppFramework\Http\Request; use OC\Files\SetupManager; use OCP\Files\Template\ITemplateManager; use OCP\IConfig; @@ -327,10 +326,9 @@ class OC_Util { return; } - $timestamp = filemtime(OC::$SERVERROOT . '/version.php'); require OC::$SERVERROOT . '/version.php'; /** @var int $timestamp */ - self::$versionCache['OC_Version_Timestamp'] = $timestamp; + self::$versionCache['OC_Version_Timestamp'] = \OC::$VERSION_MTIME; /** @var string $OC_Version */ self::$versionCache['OC_Version'] = $OC_Version; /** @var string $OC_VersionString */