Regression in system fallback for date_default_timezone_get()

Bug #1069529 reported by Dominik Angehrn
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php5 (Debian)
Fix Released
Unknown
php5 (Ubuntu)
Medium
Unassigned
Quantal
Medium
Unassigned
Raring
Medium
Unassigned

Bug Description

[Impact]

A regression of timezone handling between Precise and Quantal means that PHP scripts that depend on the system timezone now use UTC instead. This breaks arbitrary PHP scripts - eg. cactus stops working as expected.

Not affected: 5.3.10-1ubuntu3.4 (Precise)
Affected: 5.4.6-1ubuntu1 (Quantal)
Not affected: 5.4.4-7 (sid)

Workaround: edit /etc/php5/*/php.ini, uncomment the "date.timezone" line and set it to what you need.

[Test Case]

1. Set a timezone other than UTC using "dpkg reconfigure tzdata".
2. $ php -r 'echo date_default_timezone_get()."\n";'

Expected results: system timezone (eg. "Europe/London")

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

(where in this case UTC is the system timezone).

[Regression Potential]

This patch was previously used by Debian and inadvertently dropped, causing this regression. It has already been re-added in Debian. The change only touches the guess_timezone function and adds an additional fallback. If there is an inadvertent regression, it is likely to be in timezone selection code.

Revision history for this message
Paul Gevers (paul-climbing) wrote :

I believe that the php5 source package in Ubuntu (Debian) tries to make sure that in Ubuntu this is not necessary (I see patches related to using . Therefor I assume something is broken in those patches, and I reassign to php5. If somebody with more php knowledge could look into this...

Cacti just relies on php returning the proper timezone. If php can not do that, Cacti will also not be able to do that better.

affects: cacti (Ubuntu) → php5 (Ubuntu)
summary: - No graph updates after upgrade to 12.10 because date.timezone not set in
- php.ini
+ date_default_timezone_get() broken after upgrade to 12.10
Robie Basak (racb)
description: updated
summary: - 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
status: New → Triaged
Robie Basak (racb)
description: updated
Revision history for this message
Robie Basak (racb) wrote : Re: php packaging does not automatically set timezone in php.ini

Turns out that this was a regression in Debian, already fixed there in sid 5.4.4-6 and experimental 5.4.6-2.

summary: - php packaging does not automatically set timezone in php.ini
+ Regression in system fallback for date_default_timezone_get()
description: updated
information type: Public → Public Security
information type: Public Security → Public
Changed in php5 (Debian):
status: Unknown → Fix Released
Revision history for this message
Robie Basak (racb) wrote :

I've picked this patch up from the fix in Debian, and verified that this fixes Quantal in a test build. I need to prepare an SRU for Quantal from this next, and I think we'll need to have merged Debian experimental before the SRU can go in.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "fix-system-timezone.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Robie Basak (racb) wrote :

SRU debdiff attached. AIUI, this can be copied forward to raring.

description: updated
Revision history for this message
Robie Basak (racb) wrote :
Revision history for this message
Robie Basak (racb) wrote :

I have verified that the test case fails in a quantal chroot running 5.4.6-1ubuntu1, and then passes after an upgrade to my test build of 5.4.6-1ubuntu2.

Revision history for this message
Paul Gevers (paul-climbing) wrote : Re: [Bug 1069529] Re: Regression in system fallback for date_default_timezone_get()

On 24-10-12 15:41, Robie Basak wrote:
> I have verified that the test case fails in a quantal chroot running
> 5.4.6-1ubuntu1, and then passes after an upgrade to my test build of
> 5.4.6-1ubuntu2.
>

Just a stupid question. Reading the changelog of 5.4.6-2 in Debian [1],
it seems a lot of bugs were fixed in that version that were fixed in
5.4.4-6 of php5 in unstable. Have you verified that we don't ALSO really
want the other merges in 5.4.6-2?

Paul

[1] http://packages.debian.org/changelogs/pool/main/p/php5/current/changelog

Changed in php5 (Ubuntu Quantal):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

ACK on the debdiff. I've uploaded a slightly modified version of it to raring, and to quantal-proposed for processing by the SRU team. Thanks!

Changed in php5 (Ubuntu Raring):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package php5 - 5.4.6-1ubuntu2

---------------
php5 (5.4.6-1ubuntu2) raring; urgency=low

  [ Robie Basak ]
  * Re-add logic to guess default timezone from system to fix default timezone
    regression (LP: #1069529). Cherry-picked from Debian 5.4.4-6 (also in
    Debian 5.4.6-2).

  [ Marc Deslauriers ]
  * debian/patches/libxml290.patch: Fix FTBFS with libxml 2.9.0.
 -- Marc Deslauriers <email address hidden> Wed, 07 Nov 2012 11:54:55 -0500

Changed in php5 (Ubuntu Raring):
status: Fix Committed → Fix Released
Revision history for this message
Clint Byrum (clint-fewbar) wrote : Please test proposed package

Hello Dominik, or anyone else affected,

Accepted php5 into quantal-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/php5/5.4.6-1ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in php5 (Ubuntu Quantal):
status: Triaged → Fix Committed
tags: added: verification-needed
Revision history for this message
Robie Basak (racb) wrote :

Ran test case on quantal. Failed without -proposed, succeeded with -proposed.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Scott Kitterman (kitterman) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package php5 - 5.4.6-1ubuntu1.1

---------------
php5 (5.4.6-1ubuntu1.1) quantal-proposed; urgency=low

  * Re-add logic to guess default timezone from system to fix default timezone
    regression (LP: #1069529). Cherry-picked from Debian 5.4.4-6 (also in
    Debian 5.4.6-2).
 -- Robie Basak <email address hidden> Wed, 24 Oct 2012 10:04:51 +0000

Changed in php5 (Ubuntu Quantal):
status: Fix Committed → Fix Released
Revision history for this message
avdd (avdd) wrote :

12.04 precise does seem affected by this or something like it:

$ cat /etc/timezone
Australia/Sydney
$ grep date.timezone /etc/php5/cli/php.ini
; http://php.net/date.timezone
;date.timezone =
$ php -r 'print date_default_timezone_get();'
Antarctica/Macquarie$

I don't understand why PHP is so special it needs to be told indivdually about my time zone, for each installed interpreter.

Revision history for this message
Robie Basak (racb) wrote :

> Antarctica/Macquarie$

This rings a bell, but I think it's a different (perhaps related) bug that I can't find right now. This bug is when the system timezone doesn't get picked up by default at all.

> I don't understand why PHP is so special it needs to be told indivdually about my time zone, for each installed interpreter.

The upstream PHP project appear to prefer it this way, and aren't interested in changing this. So multiple distributions (Debian/Ubuntu, Fedora/RHEL/CentOS, others?) have to patch in what they think is better behaviour, and this regresses sometimes. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=618462#10 for some further background.

Revision history for this message
avdd (avdd) wrote :

Still seeing the same behaviour in 14.04:

$ cat /etc/timezone
Australia/Sydney
$ grep date.timezone /etc/php5/cli/php.ini
; http://php.net/date.timezone
;date.timezone =
$ grep -r date.timezone /etc/php5/cli
/etc/php5/cli/php.ini:; http://php.net/date.timezone
/etc/php5/cli/php.ini:;date.timezone =
$ php -r 'print date_default_timezone_get();'
Antarctica/Macquarie

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.