From 135b270807eb26cb0dcc05206a30b303a34fec93 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 27 Aug 2024 12:29:04 -0100 Subject: [PATCH] fix(setup): ignore long session login during installation Signed-off-by: Maxence Lange --- lib/base.php | 7 ++++++- lib/private/Session/Internal.php | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/base.php b/lib/base.php index f5f1588ed1815..0d5c70f8449dd 100644 --- a/lib/base.php +++ b/lib/base.php @@ -448,10 +448,15 @@ public static function initSession(): void { $sessionName = OC_Util::getInstanceId(); try { + $logger = null; + if (Server::get(\OC\SystemConfig::class)->getValue('installed', false)) { + $logger = logger('core'); + } + // set the session name to the instance id - which is unique $session = new \OC\Session\Internal( $sessionName, - logger('core'), + $logger, ); $cryptoWrapper = Server::get(\OC\Session\CryptoWrapper::class); diff --git a/lib/private/Session/Internal.php b/lib/private/Session/Internal.php index 9002132e30515..ecfab9d8b644b 100644 --- a/lib/private/Session/Internal.php +++ b/lib/private/Session/Internal.php @@ -53,8 +53,10 @@ class Internal extends Session { * @param string $name * @throws \Exception */ - public function __construct(string $name, - private LoggerInterface $logger) { + public function __construct( + string $name, + private ?LoggerInterface $logger, + ) { set_error_handler([$this, 'trapError']); $this->invoke('session_name', [$name]); $this->invoke('session_cache_limiter', ['']); @@ -228,7 +230,7 @@ private function invoke(string $functionName, array $parameters = [], bool $sile $timeSpent > 0.5 => ILogger::INFO, default => ILogger::DEBUG, }; - $this->logger->log( + $this->logger?->log( $logLevel, "Slow session operation $functionName detected", [