News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

timezone warnings on PHP 5.3

Started by MrPhil, July 02, 2011, 09:48:55 PM

Previous topic - Next topic

MrPhil

SMF 2.0 users seem to be reporting a flood of PHP error messages concerning no default timezone being defined. I'm assuming that they originally installed on a pre-PHP 5.1 system and thus do not have the default timezone set in the settings table. As SMF queries and handles this timezone name on each page, and knows the PHP version, it should be simple enough to check if you're on a PHP 5.3+ system and do not have a default timezone name. Administrators should then be notified that they need to set this timezone name (perhaps a reasonable guess could be put in the database to tide things over until the administrator can act).

If the timezone name exists in the table but it's a deprecated format (e.g., GMT+4 instead of America/New_York), it should be flagged for update to an approved name. SMF should use (if PHP 5.2+) the list of approved names to select from. It might also add in more familiar names (e.g., EST5EDT) and translate those to an approved name). If the timezone function rejects a name because it's deprecated or has been dropped, the administrator should be notified (and some default such as GMT be used).

Finally, eventually members should be given the option to choose their own timezones from the PHP-approved list (same as the administrator), instead of an hours offset.

SMF has been caught with its pants down by host upgrades to PHP 5.3. It needs a way to gracefully handle missing timezone names, rather than subjecting forum owners to ugly PHP messages. Until we can be sure there are no more pre-PHP 5.1 systems left, SMF will have to keep the hour offsets as a backup, but for PHP 5.3+ must use the timezone names.

Aleksi "Lex" Kilpinen

If it's causing a flood of errors, then it should be concidered a bug IMO, and so this post would probably belong on the bug reports board....
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

MrPhil

Bug fix or new feature, so long as it gets in the code. A mod for 1.x that does the same thing would be good, too.

青山 素子

Not an error, it's a notice. PHP as of 5.3 now issues notices when a timezone isn't set and any time functions are used, even if they wouldn't be affected by the timezone setting.

I believe SMF2 tries to set a timezone if one isn't set, but you'll still get a warning per page load.

Frankly, the hosting providers should set an appropriate timezone in the system php.ini file.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


holodoc

Quote from: 青山 素子 on July 03, 2011, 05:36:34 PMFrankly, the hosting providers should set an appropriate timezone in the system php.ini file.
Most hosting providers don't do it to prevent possible problems with customers coming from all around the world (i.e. setting a fixed timezone will most certainly calculate false time diffs if the software is not timezone aware).

MrPhil

Most hosts are going to have their servers at GMT or  the timezone they're physically located in (or one common timezone if spread across multiple timezones). I think that what 青山 素子* was suggesting is that hosts remember to set their default PHP timezone (via system php.ini or equivalent) to the same timezone. It's still up to customers to override that with their desired timezone name in their application, but at least we wouldn't be getting these error messages if they forget to do so, just the wrong time (and/or DST rules, no different from leaving the offset at 0).

The best of all worlds would be on PHP 5.1+ systems to remind users to select a proper timezone (on 5.2+ using the built-in list of names), while continuing to allow hour offsets only for pre-5.1 systems. And of course, members get to choose their own timezone, and PHP upgrades to 5.1+ generate a reminder to the administrator to set the default timezone and encourage members to set their own.

* How about restricting the alphabet for member names to ASCII? I don't have CJK font sets installed, so this name always comes out as UTF-16 codes in boxes!

青山 素子

Quote from: MrPhil on July 04, 2011, 01:16:45 PM
* How about restricting the alphabet for member names to ASCII? I don't have CJK font sets installed, so this name always comes out as UTF-16 codes in boxes!

What about using a proper modern OS that can support Unicode names directly? (If you're using broken Windows, install International language support.)
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Advertisement: