aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-06-19 09:35:46 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-06-26 10:07:22 +0200
commit8ed6086a82f64f252ac871d7790dfacdbc335f5a (patch)
tree0e67e6c109b02856487e8247fcd8d89e968946c0
parent7d7df35c2e00dd16ba47115c49cccc946189af31 (diff)
downloadnextcloud-server-8ed6086a82f64f252ac871d7790dfacdbc335f5a.tar.gz
nextcloud-server-8ed6086a82f64f252ac871d7790dfacdbc335f5a.zip
Fix user log.condition feature
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--lib/private/Log.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 1f248be1410..9aff774d0ec 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -38,17 +38,18 @@ namespace OC;
use Exception;
use Nextcloud\LogNormalizer\Normalizer;
-use OC\AppFramework\Bootstrap\Coordinator;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\ILogger;
+use OCP\IUserSession;
use OCP\Log\BeforeMessageLoggedEvent;
use OCP\Log\IDataLogger;
-use Throwable;
-use function array_merge;
-use OC\Log\ExceptionSerializer;
-use OCP\ILogger;
use OCP\Log\IFileBased;
use OCP\Log\IWriter;
use OCP\Support\CrashReport\IRegistry;
+use OC\AppFramework\Bootstrap\Coordinator;
+use OC\Log\ExceptionSerializer;
+use Throwable;
+use function array_merge;
use function strtr;
/**
@@ -274,10 +275,13 @@ class Log implements ILogger, IDataLogger {
// check for user
if (isset($logCondition['users'])) {
- $user = \OC::$server->getUserSession()->getUser();
+ $user = \OCP\Server::get(IUserSession::class)->getUser();
- // if the user matches set the log condition to satisfied
- if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) {
+ if ($user === null) {
+ // User is not known for this request yet
+ $this->logConditionSatisfied = null;
+ } elseif (in_array($user->getUID(), $logCondition['users'], true)) {
+ // if the user matches set the log condition to satisfied
$this->logConditionSatisfied = true;
}
}