Advertisement:

Author Topic: timezone warnings on PHP 5.3  (Read 7454 times)

MrPhil

  • Guest
timezone warnings on PHP 5.3
« on: July 02, 2011, 09:48:55 PM »
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.
« Last Edit: July 03, 2011, 02:51:52 AM by Norv »

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,541
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: timezone warnings on PHP 5.3
« Reply #1 on: July 03, 2011, 01:27:19 AM »
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....
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"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

MrPhil

  • Guest
Re: timezone warnings on PHP 5.3
« Reply #2 on: July 03, 2011, 12:16:14 PM »
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.

Offline 青山 素子

  • Server Team
  • SMF Super Hero
  • *
  • Posts: 17,068
  • 戦場ヶ原、蕩れ!
    • srvrguy on GitHub
    • @motokochan on Twitter
    • Nekomusume Moe
Re: timezone warnings on PHP 5.3
« Reply #3 on: July 03, 2011, 05:36:34 PM »
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.


Offline holodoc

  • Full Member
  • ***
  • Posts: 479
Re: timezone warnings on PHP 5.3
« Reply #4 on: July 04, 2011, 07:29:09 AM »
Frankly, 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

  • Guest
Re: timezone warnings on PHP 5.3
« Reply #5 on: July 04, 2011, 01:16:45 PM »
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!

Offline 青山 素子

  • Server Team
  • SMF Super Hero
  • *
  • Posts: 17,068
  • 戦場ヶ原、蕩れ!
    • srvrguy on GitHub
    • @motokochan on Twitter
    • Nekomusume Moe
Re: timezone warnings on PHP 5.3
« Reply #6 on: July 04, 2011, 05:43:13 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.