Skip to content
Draft
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
21 changes: 12 additions & 9 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,18 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
}

$user = Server::get(IUserSession::class)->getUser();
$userId = $user?->getUID();

if ($user === null) {
if (empty($userId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can userId ever be an empty string? Either its null or the userId which has to be not empty.
If there is a case where its an empty string here, then its triggered far up in the logic.

Copy link
Member Author

@solracsf solracsf Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully understand your point; the fact is the the only reports (and my own logs) about "UID empty string" are these.

If there were problems at the IUserSession::class level, there would be way more, and different, reports, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reproduce the issue? I was not able to do so.
If you can, then you could add some debugging to the User class when the user id is set to the empty string, would be good to get the stack trace there.

$page->assign('user_uid', false);
$page->assign('user_displayname', false);
$page->assign('userAvatarSet', false);
$page->assign('userStatus', false);
} else {
$page->assign('user_uid', $user->getUID());
$page->assign('user_uid', $userId);
$page->assign('user_displayname', $user->getDisplayName());
$page->assign('userAvatarSet', true);
$page->assign('userAvatarVersion', $this->config->getUserValue($user->getUID(), 'avatar', 'version', 0));
$page->assign('userAvatarVersion', $this->config->getUserValue($userId, 'avatar', 'version', 0));
}
break;
case TemplateResponse::RENDER_AS_ERROR:
Expand All @@ -143,14 +144,16 @@ public function getPageTemplate(string $renderAs, string $appId): ITemplate {
Util::addStyle('guest');
$page->assign('bodyid', 'body-login');

$userDisplayName = false;
$user = Server::get(IUserSession::class)->getUser();
if ($user) {
$userDisplayName = $user->getDisplayName();
}
$userId = $user?->getUID();

$page->assign('user_displayname', $userDisplayName);
$page->assign('user_uid', \OC_User::getUser());
if (empty($userId)) {
$page->assign('user_displayname', false);
$page->assign('user_uid', false);
} else {
$page->assign('user_displayname', $user->getDisplayName());
$page->assign('user_uid', $userId);
}
break;
case TemplateResponse::RENDER_AS_PUBLIC:
$page = $this->templateManager->getTemplate('core', 'layout.public');
Expand Down
Loading