[Bug 1069529] Re: date_default_timezone_get() broken after upgrade to 12.10
Robie Basak
1069529 at bugs.launchpad.net
Wed Oct 24 07:49:55 UTC 2012
** Description changed:
- After release upgrading from 12.04 to 12.10, I remarked that the graphs
- are not updated anymore and the modify date of the files in
- /var/lib/cacti/rra was a timestamp before the upgrade.
+ An upstream change in PHP requires php.ini to have the timezone set in
+ there, instead of PHP using the system timezone as one might expect.
- I had many lines in /var/log/cacti/poller-error.log like this one:
- PHP Warning: date(): 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 /usr/share/cacti/site/lib/functions.php on line 486
+ This is new in PHP 5.4.
- According to the FAQ page of cacti, I adjusted the php.ini in /etc/php5/cli and /etc/php5/apache2:
- http://docs.cacti.net/faq#time_zone_warning
+ Not affected: 5.3.10-1ubuntu3.4 (Precise)
+ Affected: 5.4.6-1ubuntu1 (Quantal)
- According to the PHP documentation, the behaviour in PHP 5.4 changed:
- http://www.php.net/manual/en/function.date-default-timezone-get.php
+ Workaround: edit /etc/php5/*/php.ini, uncomment the "date.timezone" line
+ and set it to what you need.
- First I thought that it is a bug of the packages php5-cli and libapache2-mod-php5 which do not set the date.timezone in their respective php.ini files. You can see that if you execute the following 2 commands:
- dpkg-query --control-show libapache2-mod-php5 postinst
- dpkg-query --control-show php5-cli postinst
+ Test Case:
- There is only the default php.ini from the package copied without
- setting the date.timezone variable or let the user choose one.
+ Run:
+ $ php -r 'echo date_default_timezone_get()."\n";'
- But then I recognized, that the PHP script is executed to the end, also
- if the date.timezone variable is not set in php.ini
+ Expected results: timezone (eg. "UTC")
-
- Let me demonstrate this in 3 examples:
-
-
- 1) Ubuntu 11.10 with timezone Europe/Zurich in /etc/timezone, no date.timezone set in php.ini and PHP version 5.3.6-13ubuntu3.9:
-
- user at hostname1:~$ echo; lsb_release -a; echo; uname -a; echo; cat
- /etc/timezone; echo; grep "date\.timezone" /etc/php5/cli/php.ini; echo;
- php -r 'echo date_default_timezone_get()."\n"; echo phpversion()."\n";
- echo date("r")."\n"; echo strtotime("now")."\n"; echo "\nall commands
- executed with success\n\n";'
-
- No LSB modules are available.
- Distributor ID: Ubuntu
- Description: Ubuntu 11.10
- Release: 11.10
- Codename: oneiric
-
- Linux hostname1 2.6.32-042stab061.2 #1 SMP Fri Aug 24 09:07:21 MSK 2012
- i686 i686 i386 GNU/Linux
-
- Europe/Zurich
-
- ; http://php.net/date.timezone
- ;date.timezone =
-
- Europe/Berlin
- 5.3.6-13ubuntu3.9
- Sun, 21 Oct 2012 22:21:12 +0200
- 1350850872
-
- all commands executed with success
-
- user at hostname1:~$
-
-
- 2) Ubuntu 12.10 with timezone Europe/Zurich in /etc/timezone, no date.timezone set in php.ini and PHP version 5.4.6-1ubuntu1:
-
- user at hostname2:~$ echo; lsb_release -a; echo; uname -a; echo; cat
- /etc/timezone; echo; grep "date\.timezone" /etc/php5/cli/php.ini; echo;
- php -r 'echo date_default_timezone_get()."\n"; echo phpversion()."\n";
- echo date("r")."\n"; echo strtotime("now")."\n"; echo "\nall commands
- executed with success\n\n";'
-
- No LSB modules are available.
- Distributor ID: Ubuntu
- Description: Ubuntu 12.10
- Release: 12.10
- Codename: quantal
-
- Linux hostname2 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC
- 2012 x86_64 x86_64 x86_64 GNU/Linux
-
- Europe/Zurich
-
- ; http://php.net/date.timezone
- ;date.timezone =
-
+ Actual results:
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 Command line code on line 1
UTC
- 5.4.6-1ubuntu1
- PHP Warning: date(): 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 Command line code on line 1
- Sun, 21 Oct 2012 19:33:45 +0000
- PHP Warning: strtotime(): 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 Command line code on line 1
- 1350848025
- all commands executed with success
-
- user at hostname2:~$
-
-
- 2) Ubuntu 12.10 with timezone Europe/Zurich in /etc/timezone, date.timezone set in php.ini to Europe/Zurich and PHP version 5.4.6-1ubuntu1:
-
- user at hostname3:~$ echo; lsb_release -a; echo; uname -a; echo; cat
- /etc/timezone; echo; grep "date\.timezone" /etc/php5/cli/php.ini; echo;
- php -r 'echo date_default_timezone_get()."\n"; echo phpversion()."\n";
- echo date("r")."\n"; echo strtotime("now")."\n"; echo "\nall commands
- executed with success\n\n";'
-
- No LSB modules are available.
- Distributor ID: Ubuntu
- Description: Ubuntu 12.10
- Release: 12.10
- Codename: quantal
-
- Linux hostname3 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC
- 2012 x86_64 x86_64 x86_64 GNU/Linux
-
- Europe/Zurich
-
- ; http://php.net/date.timezone
- date.timezone = "Europe/Zurich"
-
- Europe/Zurich
- 5.4.6-1ubuntu1
- Sun, 21 Oct 2012 21:35:16 +0200
- 1350848116
-
- all commands executed with success
-
- user at hostname3:~$
-
-
- I am really not sure whether this is a bug in cacti (because the graphs
- are not updated although the not set timezone in php.ini should let the
- poller finish his work) or in php5-cli/libapache2-mod-php5 (which should
- either interact with the user to ask which timezone to set in the
- php.ini or take the timezone from /etc/timezone), I just recognized that
- the graphs in cacti did not update after the release upgrade and it
- worked again after setting date.timezone in both php.ini files and
- reloading apache2.
-
- IMHO it has to be solved either in the cacti package or the bug should
- be assigned to php5-cli and libapache2-mod-php5 to let them set the
- date.timezone variable in the postinstall routine.
-
-
- package versions:
- user at hostname3:~$ LC_ALL=C apt-cache policy cacti
- cacti:
- Installed: 0.8.8a-3
- Candidate: 0.8.8a-3
- Version table:
- *** 0.8.8a-3 0
- 500 http://ch.archive.ubuntu.com/ubuntu/ quantal/universe amd64 Packages
- 100 /var/lib/dpkg/status
- user at hostname3:~$ LC_ALL=C apt-cache policy php5-cli
- php5-cli:
- Installed: 5.4.6-1ubuntu1
- Candidate: 5.4.6-1ubuntu1
- Version table:
- *** 5.4.6-1ubuntu1 0
- 500 http://ch.archive.ubuntu.com/ubuntu/ quantal/main amd64 Packages
- 100 /var/lib/dpkg/status
- user at hostname3:~$ LC_ALL=C apt-cache policy libapache2-mod-php5
- libapache2-mod-php5:
- Installed: 5.4.6-1ubuntu1
- Candidate: 5.4.6-1ubuntu1
- Version table:
- *** 5.4.6-1ubuntu1 0
- 500 http://ch.archive.ubuntu.com/ubuntu/ quantal/main amd64 Packages
- 100 /var/lib/dpkg/status
- user at hostname3:~$
+ (where in this case UTC is the system timezone).
** Summary changed:
- date_default_timezone_get() broken after upgrade to 12.10
+ php packaging does not automatically set timezone in php.ini
** Changed in: php5 (Ubuntu)
Importance: Undecided => Medium
** Changed in: php5 (Ubuntu)
Status: New => Triaged
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to php5 in Ubuntu.
https://bugs.launchpad.net/bugs/1069529
Title:
php packaging does not automatically set timezone in php.ini
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1069529/+subscriptions
More information about the Ubuntu-server-bugs
mailing list