Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Timezone Bug #335

Closed
wants to merge 3 commits into from
Closed

Fix Timezone Bug #335

wants to merge 3 commits into from

Conversation

thotam
Copy link

@thotam thotam commented Feb 24, 2024

Fix Timezone always UTC

@arukompas
Copy link
Contributor

Hey @thotam , can you explain what exactly is the bug?

@thotam
Copy link
Author

thotam commented Feb 29, 2024

Hey @thotam , can you explain what exactly is the bug?

Because when defined timezone in log-viewer.php file is NULL. The config('log-viewer.timezone', 'Value') always return NULL whatever the Value you set is. So $timezone = config('log-viewer.timezone', config('app.timezone', 'UTC')) ?? 'UTC'; will always is UTC
Follow this docs

A default value may also be specified and will be returned if the configuration option does not exist

@arukompas
Copy link
Contributor

hey @thotam I see! Thanks for explaining 😄

First of all, the timezone selection currently works as expected, even if the log viewer's timezone is set to null, because of the LogViewer::timezone() function taking care of defaulting to the app's timezone and finally to UTC.

public function timezone(): string
{
if (! isset($this->_cachedTimezone)) {
$this->_cachedTimezone = config('log-viewer.timezone')
?? config('app.timezone')
?? 'UTC';
}
return $this->_cachedTimezone;
}

And second, you're not supposed to use config() function inside config files, because Laravel does not guarantee any particular loading order for config files, and it could be that log-viewer.php is loaded before app.php is loaded, therefore not able to get the value.

This currently works as intended, so no change necessary. Closing.

@arukompas arukompas closed this Mar 1, 2024
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.

2 participants