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
Contributor

commented Apr 15, 2019

No description provided.

@Al2Klimov Al2Klimov requested a review from nilmerg Apr 15, 2019

@nilmerg
Copy link
Member

left a comment

Why?

@Al2Klimov

This comment has been minimized.

Copy link
Contributor Author

commented Apr 16, 2019

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

This comment has been minimized.

Copy link
Member

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 Al2Klimov reopened this Apr 16, 2019

@Al2Klimov Al2Klimov force-pushed the bugfix/setuptimezone branch from 00e0073 to 5d4cdfe Apr 16, 2019

@Al2Klimov Al2Klimov requested a review from nilmerg Apr 16, 2019

@Al2Klimov

This comment has been minimized.

Copy link
Contributor Author

commented Apr 16, 2019

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 label Apr 17, 2019

@nilmerg nilmerg merged commit b50091f into master Apr 17, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@nilmerg nilmerg deleted the bugfix/setuptimezone branch Apr 17, 2019

nilmerg added a commit that referenced this pull request Apr 18, 2019

Merge pull request #3747 from Icinga/bugfix/setuptimezone
ApplicationBootstrap#setupTimezone(): ensure a vaild default timezone to be set in any case

(cherry picked from commit b50091f)
Signed-off-by: Johannes Meyer <johannes.meyer@icinga.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.