Bug #3016

Wrong timezone in php.ini cause PHP localtime() function to report time different from date shell command

Added by Stefano Fancello over 6 years ago. Updated over 6 years ago.

Status:CLOSEDStart date:
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:nethserver-php
Target version:v6.6-rc1
Security class: Resolution:REJECTED
Affected version:v6.5-final NEEDINFO:No

Description

php.ini template has default timezone to "UTC"

 # cat /etc/e-smith/templates/etc/php.ini/10base
...
date.timezone = "{ $php{DateTimezone} || 'UTC' }" 

by default DateTimezone in php key is also "UTC"
# cat /etc/e-smith/db/configuration/defaults/php/DateTimezone 
UTC

# config show php
php=configuration
...
    DateTimezone=UTC

But NethServer configuration database already has this information in db key TimeZone
# config show TimeZone
TimeZone=Europe/Rome

I think that the default value of this variable should be the system timezone and not "UTC".
Is there any reason it was setted to UTC?

references:
http://php.net/manual/en/datetime.configuration.php
http://php.net/manual/en/function.date-default-timezone-get.php
http://php.net/manual/en/function.localtime.php


Related issues

Copied to NethServer 6 - Enhancement #3068: Set PHP default timezone from system timezone CLOSED

Associated revisions

Revision 0bb222cc
Added by Stefano Fancello over 6 years ago

Default php timezone is now empty. If php timezone isn't defined by user, php.ini template try to use system timezone after checking if it is recognized by php interpreter. If it's not, default is set to UTC. Refs #3016

Revision 2f5cb069
Added by Davide Principi over 6 years ago

Added PHP date.timezone note for 6.6 release. Refs #3016

Revision 88efd6e5
Added by Davide Principi over 6 years ago

docs: Added php/DateTimezone deprecation statement. Refs #3016

Revision 3676a01d
Added by Davide Principi over 6 years ago

Reverted commit 0bb222c. Refs #3016

The PHP timezone setting is delegated to Server Manager, during first
configurazion wizard in nethserver-ntp package.

Revision 2cb7b28d
Added by Davide Principi over 6 years ago

Reverted changes for PHP date.timezone settings. Refs #3016 #3068

Revision bbbc0481
Added by Davide Principi over 6 years ago

Merge pull request #53 from DavidePrincipi/master

Added PHP date.timezone note for 6.6 release. Refs #3016 #3068

History

#1 Updated by Stefano Fancello over 6 years ago

Workaround:

 # config setprop php DateTimezone $(config get TimeZone)
 # expand-template /etc/php.ini

Reload httpd

#2 Updated by Davide Principi over 6 years ago

  • Subject changed from wrong timezone in php.in cause php lcoaltime() function to report time different from date shell command to Wrong timezone in php.ini cause PHP localtime() function to report time different from date shell command

#3 Updated by Davide Principi over 6 years ago

Stefano Fancello wrote:

I think that the default value of this variable should be the system timezone and not "UTC".
Is there any reason it was setted to UTC?

Web apps should provide a way to customize it according to their business rules.

Having said that, in NethServer context, the TimeZone key could be a good default, provided its value is a valid value for date.timezone, too!

#4 Updated by Stefano Fancello over 6 years ago

  • Status changed from NEW to TRIAGED
  • % Done changed from 0 to 20

#5 Updated by Stefano Fancello over 6 years ago

  • Status changed from TRIAGED to ON_DEV
  • Assignee set to Stefano Fancello
  • % Done changed from 20 to 30

#6 Updated by Stefano Fancello over 6 years ago

  • Status changed from ON_DEV to MODIFIED
  • % Done changed from 30 to 60

Test case:
check that php.ini is correct when TimeZone and php DateTimezone are changed and php.ini is expanded:

1

 # config set TimeZone Europe/Rome
 # config setprop php DateTimezone "" 
 # expand-template /etc/php.ini && grep date.timezone /etc/php.ini
date.timezone = "Europe/Rome" 

2

 # config set TimeZone Europe/Rome
 # config setprop php DateTimezone Australia/Lindeman
 # expand-template /etc/php.ini && grep date.timezone /etc/php.ini
date.timezone = "Australia/Lindeman" 

3

 # config set TimeZone foo/bar
 # config setprop php DateTimezone "" 
 # expand-template /etc/php.ini && grep date.timezone /etc/php.ini
date.timezone = "UTC" 

4

 # config set TimeZone foo/bar
 # config setprop php DateTimezone Australia/Lindeman
 # expand-template /etc/php.ini && grep date.timezone /etc/php.ini
date.timezone = "Australia/Lindeman" 

#7 Updated by Stefano Fancello over 6 years ago

  • Status changed from MODIFIED to ON_QA
  • % Done changed from 60 to 70

Repository nethserver-testing
Package nethserver-php-1.1.1-1.0git0bb222cc.ns6.noarch.rpm

#8 Updated by Stefano Fancello over 6 years ago

  • Assignee deleted (Stefano Fancello)

#9 Updated by Stefano Fancello over 6 years ago

NOTE
This solution doesn't fix previously installed nethserver-php, because php DateTimezone was defaulted to 'UTC' , and it remains 'UTC' unless it's not manually changed to something else.
workaround with new package is:

 # config setprop php DateTimezone "" 
 # expand-template /etc/php.ini
and restart httpd

#10 Updated by Davide Principi over 6 years ago

  • Assignee set to Davide Principi

#11 Updated by Davide Principi over 6 years ago

  • Status changed from ON_QA to VERIFIED
  • Assignee deleted (Davide Principi)
  • % Done changed from 70 to 90
  • Affected version set to v6.5-final

VERIFIED

Why not remove this prop in the future? The default system TimeZone should be a good default. From the application point of view, it can be simply ignored.

I've modified the 6.6 Release notes

https://github.com/nethesis/nethserver-docs/pull/53

#12 Updated by Giacomo Sanchietti over 6 years ago

  • Target version changed from v6.5 to v6.6-rc1

#13 Updated by Davide Principi over 6 years ago

  • Status changed from VERIFIED to CLOSED
  • % Done changed from 90 to 100
  • Resolution set to REJECTED

REJECTED

The solution to this bug has been rejected: the default PHP timezone setting is now delegated to the Server Manager, in nethserver-ntp.

In nethserver-testing 6.6
nethserver-php-1.1.1-1.4.g3676a01.ns6.noarch.rpm

#14 Updated by Davide Principi over 6 years ago

Also available in: Atom PDF