Skip to content

[3.0] Fix invalid timezone#9075

Merged
jdarwood007 merged 1 commit intoSimpleMachines:release-3.0from
jdarwood007:3.0/safeTimezone
Jan 24, 2026
Merged

[3.0] Fix invalid timezone#9075
jdarwood007 merged 1 commit intoSimpleMachines:release-3.0from
jdarwood007:3.0/safeTimezone

Conversation

@jdarwood007
Copy link
Copy Markdown
Member

The main issue is the user has an invalid timezone in their profile. Doing a check for an empty profile is simple, but a garbage entry is another issue.

https://www.php.net/manual/en/datetimezone.construct.php

According to the documentation an invalid timezone throws an error. Our code is assuming in many places that a valid time zone will be returned. The exception is not being handled

Create a wrapper and attempt to fallback the forum default time zone if we fail to get a valid user time zone Anywhere we use UTC, I ignored using the wrapper.

Fixes #9037

The main issue is the user has an invalid timezone in their profile.  Doing a check for an empty profile is simple, but a garbage entry is another issue.

https://www.php.net/manual/en/datetimezone.construct.php

According to the documentation an invalid timezone throws an error.
Our code is assuming in many places that a valid time zone will be returned.  The exception is not being handled

Create a wrapper and attempt to fallback the forum default time zone if we fail to get a valid user time zone
Anywhere we use UTC, I ignored using the wrapper.

Fixes SimpleMachines#9037
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Jan 17, 2026
@jdarwood007 jdarwood007 merged commit 84ddee6 into SimpleMachines:release-3.0 Jan 24, 2026
7 checks passed
@jdarwood007 jdarwood007 deleted the 3.0/safeTimezone branch January 24, 2026 00:16
@Sesquipedalian
Copy link
Copy Markdown
Member

SMF\TimeZone::create() should return an instance of SMF\TimeZone, not \DateTimeZone.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.0]: Unknown or bad timezone

2 participants