bgarrels / textpattern

Automatically exported from code.google.com/p/textpattern
0 stars 0 forks source link

Set default timezone if missing to avoid countless date errors #399

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have installed Textpattern 4.5.5 for the nth time to a MediaTemple DV server 
which, by default, does not have the PHP timezone set correctly for 
Textpattern. Forgive my lack of PHP knowledge, but I can resolve this by 
setting the date.timezone in textpattern/config.php, which I do.

Each time I install, I expect a lot of PHP warning errors relating to the 
initial SQL setup, specifically this over and over:

Warning: strftime(): 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 
/var/www/vhosts/example.com/httpdocs/textpattern/setup/txpsql.php on line 466

Today, for the first time, I counted the number of errors output on the 'That 
went well' page: the message above appeared above 1157 times in a row. Is there 
a feasible way to check, during install, for a suitable timezone setting and 
then, perhaps, apply it to the copy + paste configuration file page if it needs 
to be applied, perhaps letting the user select from a drop down or PHP time 
zone list?

Original issue reported on code.google.com by gaek...@gmail.com on 13 Nov 2013 at 12:05

GoogleCodeExporter commented 9 years ago
PHP's configuration files should contain server's default timezone. If its not 
set, each date function will give a warning. You should add it there rather 
than anywhere else.

Textpattern's timezone/date handling is bit incomplete and outdated, so yes, we 
could actually suppress those warnings away. We could add the statement to the 
config file, but I would rather set it programmatically when missing. You of 
course will get wrong server timezone, but hey, you really should configure it 
in the first place.

The config might be used elsewhere too and adding there something that actually 
does something rather than just data, isn't the most ideal solution.

Original comment by jukka.m.svahn on 24 Nov 2013 at 12:23