Hi!
I'm having major issues to get chatrooms work in latest version (currently 2.9) in D6. I'm running on "PHP 5.3.5" server and created a chatroom with default settings and once I go to the room I get PHP fatal error.
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [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/Helsinki' for 'EET/2.0/no DST' instead' in /var/www/html/sites/all/modules/chatroom/chatroom.module:1217 Stack trace: #0 /var/www/html/sites/all/modules/chatroom/chatroom.module(1217): DateTime->__construct('@1295640434') #1 /var/www/html/sites/all/modules/chatroom/chatroom.module(1204): chatroom_get_message_time_string('1295633234') #2 /var/www/html/sites/all/modules/chatroom/chatroom.theme.inc(326): chatroom_chat_get_themed_message(Object(stdClass), Object(stdClass)) #3 [internal function]: theme_chatroom_chat(Object(stdClass)) #4 /var/www/html/ur in /var/www/html/sites/all/modules/chatroom/chatroom.module on line 1217
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedthanks for the report, i'll look into it.
Comment #2
iMiksuHi!
It seems that PHP requires to declare timezone before setting up DateTime object. In PHP 5.3 it throws an exception unlike 5.2 so this problem applies only in PHP 5.3.
However, this should respect Drupal user's timezone settings which is in offset in seconds. By doing little research I found that you do not have to use human friendly strings to setup timezone object (like in my case, it would be "Europe/Helsinki"). But you can also use format "Etc/GMT+X". So by this modification I became into this solution which fixes this issue.
Hope this helps you to fix this issue!
Comment #3
iMiksuComment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedthanks, committed modified version here:
http://drupal.org/cvs?commit=491418
Comment #5
dmuth CreditAttribution: dmuth commentedThis is still happening as of 6.x-2.13, and causing my site to get "502 Server Errors"(!), so I wrote a patch:
Here's a diff from Git. Let me know if you need it in another format:
From looking at my logs, I've seen crazy messages like these: DateTimeZone::__construct() [function.DateTimeZone---construct]: Unknown or bad timezone (Etc/GMT+21) in /path/to/modules/chatroom/chatroom.module on line 122
Given that that timezone was a string, and a number of some sort of was expected, this function is clearly being fed bad data from somewhere. The sanest thing to do in this place is to enclose the entire thing in a try/catch block, and log when there's any issues. Hopefully enough people logging when this issue happens will provide enough data on the underlying condition.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks, will review shortly.
Comment #7
AlexisWilke CreditAttribution: AlexisWilke commentedI'm not too sure, by the catch() uses new DateTimeZone('Etc/GMT' . $offset_in_hours); with the offset... 8-)
Anyway, I found this page which says that the function only supports 'UTC'.
http://us.php.net/manual/en/timezones.others.php
Now, I wish that the format_date() from Core work properly instead of how it currently works: not properly.
I did get this error too and I fixed my version with a simple:
This works for me, but I wonder... how does it work for other users?!
Thank you.
Alexis Wilke
Comment #8
AlexisWilke CreditAttribution: AlexisWilke commentedI also noticed that you were using the same code in the chatroomread.php ... so if a fix is found for the .module, make sure the other file gets fixed too.
Thank you.
Alexis