Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logger): ignore session logging during setup #47521

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
// slash which is required by URL generation.
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT &&
substr($_SERVER['REQUEST_URI'], -1) !== '/') {
header('Location: '.\OC::$WEBROOT.'/');

Check failure on line 144 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:144:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
exit();
}
}
Expand Down Expand Up @@ -223,7 +223,7 @@
throw new Exception('Not installed');
} else {
$url = OC::$WEBROOT . '/index.php';
header('Location: ' . $url);

Check failure on line 226 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:226:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
}
exit();
}
Expand Down Expand Up @@ -387,10 +387,15 @@
$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);
Expand Down
8 changes: 5 additions & 3 deletions lib/private/Session/Internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,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', ['']);
Expand Down Expand Up @@ -204,7 +206,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",
[
Expand Down
Loading