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

ApplicationBootstrap#setupTimezone(): ensure a vaild default timezone to be set in any case #3747

Merged
merged 1 commit into from
Apr 17, 2019

Conversation

Al2Klimov
Copy link
Member

No description provided.

@Al2Klimov Al2Klimov requested a review from nilmerg April 15, 2019 15:08
Copy link
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

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

Why?

@Al2Klimov
Copy link
Member Author

Just before this one we check @date_default_timezone_get() for either a configured timezone or a fallback timezone, but we suppress errors... and future callers of date_default_timezone_get() may not suppress any errors:

[root@07b1f18d5654 /]# php -v
PHP 5.6.31 (cli) (built: Jul  6 2017 05:27:03)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
[root@07b1f18d5654 /]# php -a
Interactive shell

php > var_dump(@date_default_timezone_get());
string(3) "UTC"
php > var_dump(date_default_timezone_get());
PHP Warning:  date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in php shell code on line 1
string(3) "UTC"
php > date_default_timezone_set(@date_default_timezone_get());
php > var_dump(date_default_timezone_get());
string(3) "UTC"
php >

@nilmerg
Copy link
Member

nilmerg commented Apr 16, 2019

future callers of date_default_timezone_get() may not suppress any errors

Good. We didn't require setting date.timezone without reason after all. Anyone who doesn't care about this requirement should be reminded about it as often as possible.

@nilmerg nilmerg closed this Apr 16, 2019
@Al2Klimov
Copy link
Member Author

We're already trying to set a timezone if not set. But we miss it on PHP 5.6 where @date_default_timezone_get() returns just a fallback tz. date_default_timezone_get() (w/o @) would still produce an error w/o date_default_timezone_set().

@nilmerg nilmerg added this to the 2.6.3 milestone Apr 17, 2019
@nilmerg nilmerg added the bug Something isn't working label Apr 17, 2019
@nilmerg nilmerg merged commit b50091f into master Apr 17, 2019
@nilmerg nilmerg deleted the bugfix/setuptimezone branch April 17, 2019 12:46
nilmerg added a commit that referenced this pull request Apr 18, 2019
ApplicationBootstrap#setupTimezone(): ensure a vaild default timezone to be set in any case

(cherry picked from commit b50091f)
Signed-off-by: Johannes Meyer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants