Skip to content

Commit 2d81c04

Browse files
authored
Merge pull request #38881 from nextcloud/fix/logcondition-user
Fix user log.condition feature
2 parents 39a0554 + 8ed6086 commit 2d81c04

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/private/Log.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@
3838

3939
use Exception;
4040
use Nextcloud\LogNormalizer\Normalizer;
41-
use OC\AppFramework\Bootstrap\Coordinator;
4241
use OCP\EventDispatcher\IEventDispatcher;
42+
use OCP\ILogger;
43+
use OCP\IUserSession;
4344
use OCP\Log\BeforeMessageLoggedEvent;
4445
use OCP\Log\IDataLogger;
45-
use Throwable;
46-
use function array_merge;
47-
use OC\Log\ExceptionSerializer;
48-
use OCP\ILogger;
4946
use OCP\Log\IFileBased;
5047
use OCP\Log\IWriter;
5148
use OCP\Support\CrashReport\IRegistry;
49+
use OC\AppFramework\Bootstrap\Coordinator;
50+
use OC\Log\ExceptionSerializer;
51+
use Throwable;
52+
use function array_merge;
5253
use function strtr;
5354

5455
/**
@@ -274,10 +275,13 @@ public function getLogLevel($context) {
274275

275276
// check for user
276277
if (isset($logCondition['users'])) {
277-
$user = \OC::$server->getUserSession()->getUser();
278+
$user = \OCP\Server::get(IUserSession::class)->getUser();
278279

279-
// if the user matches set the log condition to satisfied
280-
if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) {
280+
if ($user === null) {
281+
// User is not known for this request yet
282+
$this->logConditionSatisfied = null;
283+
} elseif (in_array($user->getUID(), $logCondition['users'], true)) {
284+
// if the user matches set the log condition to satisfied
281285
$this->logConditionSatisfied = true;
282286
}
283287
}

0 commit comments

Comments
 (0)