Skip to content

Commit 028d59c

Browse files
Merge pull request #47550 from nextcloud/backport/47521/stable30
[stable30] fix(logger): ignore session logging during setup
2 parents 3df82a1 + 5df51db commit 028d59c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/base.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,15 @@ public static function initSession(): void {
387387
$sessionName = OC_Util::getInstanceId();
388388

389389
try {
390+
$logger = null;
391+
if (Server::get(\OC\SystemConfig::class)->getValue('installed', false)) {
392+
$logger = logger('core');
393+
}
394+
390395
// set the session name to the instance id - which is unique
391396
$session = new \OC\Session\Internal(
392397
$sessionName,
393-
logger('core'),
398+
$logger,
394399
);
395400

396401
$cryptoWrapper = Server::get(\OC\Session\CryptoWrapper::class);

lib/private/Session/Internal.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ class Internal extends Session {
2929
* @param string $name
3030
* @throws \Exception
3131
*/
32-
public function __construct(string $name,
33-
private LoggerInterface $logger) {
32+
public function __construct(
33+
string $name,
34+
private ?LoggerInterface $logger,
35+
) {
3436
set_error_handler([$this, 'trapError']);
3537
$this->invoke('session_name', [$name]);
3638
$this->invoke('session_cache_limiter', ['']);
@@ -204,7 +206,7 @@ private function invoke(string $functionName, array $parameters = [], bool $sile
204206
$timeSpent > 0.5 => ILogger::INFO,
205207
default => ILogger::DEBUG,
206208
};
207-
$this->logger->log(
209+
$this->logger?->log(
208210
$logLevel,
209211
"Slow session operation $functionName detected",
210212
[

0 commit comments

Comments
 (0)