Skip to content

fix(core): resolve user timezone via IUserSession in DateTimeZone - #66522

Open
isihussain wants to merge 1 commit into
nextcloud:masterfrom
isihussain:fix/datetimezone-user-session
Open

isihussain wants to merge 1 commit into
nextcloud:masterfrom
isihussain:fix/datetimezone-user-session

Conversation

@isihussain

Copy link
Copy Markdown

Summary

  • When DateTimeZone is constructed during early app registration, it captures the initial Memory session before session initialization. Consequently, subsequent calls to IDateTimeZone::getTimeZone() without an explicit $userId read user_id as null from the stale session reference and fallback to UTC.
  • Inject ?IUserSession $userSession = null into DateTimeZone and check $this->userSession?->getUser()?->getUID() before falling back to $this->session->get('user_id').
  • Keeps existing behavior intact for CLI / background jobs and explicit $userId calls.
  • Adds unit tests in tests/lib/DateTimeZoneTest.php.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit) are included
  • Screenshots before/after for front-end changes (N/A)
  • Documentation has been updated or is not required

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

When DateTimeZone is initialized during early registration, it captures
the initial session (where user_id is null). By checking IUserSession when
no explicit userId is provided, web requests resolve the authenticated
user preference while keeping session fallback for CLI and background jobs.

Signed-off-by: isihussain <35667459+isihussain@users.noreply.github.com>
@isihussain
isihussain requested a review from a team as a code owner November 11, 2026 12:19
@isihussain
isihussain requested review from Altahrim and CarlSchwan and removed request for a team November 11, 2026 12:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: IDateTimeZone ignores the user's timezone in web requests (captures pre-login session), availability saved as UTC

1 participant