6.0.0-beta1
7/6/25

[#9608] Add date_default_timezone_set to avoid E_WARNING's
Summary Add date_default_timezone_set to avoid E_WARNING's
Queue Horde Framework Packages
Queue Version Git master
Type Enhancement
State Rejected
Priority 1. Low
Owners
Requester mindboosternoori (at) gmail (dot) com
Created 02/28/2011 (5242 days ago)
Due
Updated 09/16/2016 (3215 days ago)
Assigned
Resolved 02/28/2011 (5242 days ago)
Milestone
Patch Yes

History
09/16/2016 01:32:47 PM mindboosternoori (at) gmail (dot) com Comment #7 Reply to this comment
The patch (attached) can be fetched from github directly if you 
prefer: 
https://github.com/marado/horde/commit/18140f6dd5b8f964b0d2dcc648f7d4b578199712
For reference, the patch is here: 
https://github.com/horde/horde/pull/6/commits/18140f6dd5b8f964b0d2dcc648f7d4b578199712

02/28/2011 05:00:39 PM Jan Schneider Comment #6
State ⇒ Rejected
Reply to this comment
The error message already clearly explains what to do.

Beside that, we already set the timezone in Horde application context, 
if a timezone is set in the user's preferences, either by the user, or 
by the admin setting a default.
02/28/2011 04:49:20 PM mindboosternoori (at) gmail (dot) com Comment #5 Reply to this comment
Why not set it in php.ini?
Fair enough... but if this is a requirement of Horde (or IMP at 
least), then let me suggest, instead of the initial feature request, 
that both the INSTALL documentation and test.php should reflect that 
(by mentioning that it needs to be set up in the first one, and 
testing if it is properly set up in the second one)...
02/28/2011 04:06:06 PM Chuck Hagenbuch Comment #4 Reply to this comment
Why not set it in php.ini?
02/28/2011 03:54:48 PM mindboosternoori (at) gmail (dot) com Comment #3 Reply to this comment
These are actually pretty expensive calls, and there's no reason to 
do them every single time. The responsibility of configuring the 
default timezone is also, in my opinion, outside the responsibility 
of the Log package. Why do you feel like this should be done in 
Horde_Log?
You're right, they are expensive (but mandatory) and it only needs to 
be called once (but it needs to). I've added it there since I couldn't 
find anywhere else where to add it and be 100% sure that date would 
never be called without date_default_timezone_set being previously 
called. I've seen this issue on Horde_Log happening in an "intrusive" 
way in at least two different "actions": horde/bin/db_migrate and 
while trying to use Imp.

On horde/bin/db_migrate it is only annoying, and this one line in that 
script will correct it. On the other hand, on IMP this message appears 
in the alert popup's, and the calls made (for instance to see the 
messages in one folder) have the E_WARNING returned instead of the 
expected result, making IMP unusable:

Post: 
[...]/horde/services/ajax.php/imp/viewPort?checkcache=1&slice=1%3A91&view=INBOX
Response body: 
/*-secure-{"response":null,"msgs":[{"charset":"UTF-8","message":"DateTime::__construct(): 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 'Europe\/Paris' for 'WET\/0,0\/no DST' 
instead","flags":[],"type":"horde.error"}]}*/

Once again, I believe that there might be a place (that I can try to 
find out, if you think this is the way to go) on IMP to make the 
date_default_timezone_set, but I'm afraid more places will have the 
Logger calls without the previous date_default_timezone_set ...

Anyway, please tell me how do you think this should be properly fixed. 
If you think we should add this on what calls Logger and not in Logger 
itself, I can work on submitting a patch to fix this issue on the 
places I've found out using Logger this way.
02/28/2011 03:22:07 PM Chuck Hagenbuch Comment #2
Priority ⇒ 1. Low
State ⇒ Feedback
Reply to this comment
These are actually pretty expensive calls, and there's no reason to do 
them every single time. The responsibility of configuring the default 
timezone is also, in my opinion, outside the responsibility of the Log 
package. Why do you feel like this should be done in Horde_Log?
02/28/2011 02:29:28 PM mindboosternoori (at) gmail (dot) com Comment #1
Priority ⇒ 3. High
Type ⇒ Enhancement
Summary ⇒ Add date_default_timezone_set to avoid E_WARNING's
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ Yes
New Attachment: 18140f6.patch Download
State ⇒ New
Reply to this comment
I added date_default_timezone_set to avoid E_WARNING's at 
Horde_Log_Logger. This is being setted up as "high priority" since 
this warnings appear as popups every time a user tries to do something 
on imp (besides having the server's error log full of warnings).

More info at 
http://php.net/manual/en/function.date-default-timezone-set.php , but, 
basicly, since PHP 5.1.0 you have to date_default_timezone_set before 
using date (or else you'll get an E_WARNING), and that's not being 
done at Horde_Log_Logger. The patch is a simple one liner, and will 
work in previous PHP versions (if the function doesn't exist, then it 
doesn't try to use it).

The patch (attached) can be fetched from github directly if you 
prefer: 
https://github.com/marado/horde/commit/18140f6dd5b8f964b0d2dcc648f7d4b578199712

Saved Queries