Page MenuHomePhabricator

Users with unknown or bad timezones can't log in
Closed, ResolvedPublic

Description

Make it so that users can still log in even if they have a bogus timezone stored in user_properties. Currently HHVM systems won't even let them log in due to unhandled exceptions; Zend PHP systems will let them interact with the wiki but the server log will get spewed with PHP warnings.


Original issue:

User:Qian.Nivan cannot login at fawiki due to "Unknown or bad timezone"

Reported at https://meta.wikimedia.org/wiki/Wikimedia_Forum#Please_Help (permalink). Attempts to log in at fawiki throws an exception. Initially I thought this was T119736 but https://meta.wikimedia.org/wiki/Special:CentralAuth/Qian.Nivan works okay and @Tgr said that the log says authentication succeeded but there are SessionManager errors.

Event Timeline

Glaisher created this task.Jun 7 2016, 5:38 AM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJun 7 2016, 5:38 AM
Reedy added a subscriber: Reedy.EditedJun 7 2016, 1:23 PM

DateTimeZone::__construct(): Unknown or bad timezone (America/Istanbul)

archive/exception.log-20160603.gz:2016-06-03 05:29:22 [V1EVsgpAEIEAAGhLRqQAAABA] mw1149 fawiki 1.28.0-wmf.4 exception ERROR: [V1EVsgpAEIEAAGhLRqQAAABA] /wiki/%D8%A8%D8%AD%D8%AB_%DA%A9%D8%A7%D8%B1%D8%A8%D8%B1:Qian.Niv   Exception from line 2081 of /srv/mediawiki/php-1.28.0-wmf.4/languages/Language.php: DateTimeZone::__construct(): Unknown or bad timezone (America/Istanbul) {"exception_id":"V1EVsgpAEIEAAGhLRqQAAABA"} 
archive/exception.log-20160603.gz:[Exception Exception] (/srv/mediawiki/php-1.28.0-wmf.4/languages/Language.php:2081) DateTimeZone::__construct(): Unknown or bad timezone (America/Istanbul)
archive/exception.log-20160603.gz:  #0 /srv/mediawiki/php-1.28.0-wmf.4/languages/Language.php(2081): timezone_open(string)
archive/exception.log-20160603.gz:  #1 /srv/mediawiki/php-1.28.0-wmf.4/languages/Language.php(2361): Language->userAdjust(string, string)
archive/exception.log-20160603.gz:  #2 /srv/mediawiki/php-1.28.0-wmf.4/languages/Language.php(2392): Language->internalUserTimeAndDate(string, string, User, array)
archive/exception.log-20160603.gz:  #3 /srv/mediawiki/php-1.28.0-wmf.4/includes/skins/Skin.php(841): Language->userDate(string, User)
archive/exception.log-20160603.gz:  #4 /srv/mediawiki/php-1.28.0-wmf.4/includes/skins/SkinTemplate.php(410): Skin->lastModified()
archive/exception.log-20160603.gz:  #5 /srv/mediawiki/php-1.28.0-wmf.4/includes/skins/SkinTemplate.php(246): SkinTemplate->prepareQuickTemplate(OutputPage)
archive/exception.log-20160603.gz:  #6 /srv/mediawiki/php-1.28.0-wmf.4/includes/OutputPage.php(2324): SkinTemplate->outputPage()
archive/exception.log-20160603.gz:  #7 /srv/mediawiki/php-1.28.0-wmf.4/includes/MediaWiki.php(754): OutputPage->output()
archive/exception.log-20160603.gz:  #8 /srv/mediawiki/php-1.28.0-wmf.4/includes/MediaWiki.php(520): MediaWiki->main()
archive/exception.log-20160603.gz:  #9 /srv/mediawiki/php-1.28.0-wmf.4/index.php(43): MediaWiki->run()
archive/exception.log-20160603.gz:  #10 /srv/mediawiki/w/index.php(3): include(string)
archive/exception.log-20160603.gz:  #11 {main}
Reedy added a comment.Jun 7 2016, 1:29 PM
mysql:wikiadmin@db1041 [fawiki]> select * from user_properties where up_user = 335001 AND up_property = 'timecorrection';
+---------+----------------+-------------------------------+
| up_user | up_property    | up_value                      |
+---------+----------------+-------------------------------+
|  335001 | timecorrection | ZoneInfo|180|America/Istanbul |
+---------+----------------+-------------------------------+
1 row in set (0.00 sec)

mysql:wikiadmin@db1041 [fawiki]> delete from user_properties where up_user = 335001 AND up_property = 'timecorrection';
Query OK, 1 row affected (0.04 sec)

mysql:wikiadmin@db1041 [fawiki]>
Reedy added a comment.Jun 7 2016, 1:39 PM

Do we have a bug about handling invalid timezones better?

Do we have a bug about handling invalid timezones better?

There has been an Echo-related task in T73489: Echo: Special:Notifications Exception from line of : DateTimeZone::__construct(): Unknown or bad timezone (+00:00) (boiling down to HHVM?) plus another HHVM related task from 2014 in T54334: Unknown or bad timezone (America/Pau dos Ferros) in Preferences.php on line 655.

Wondering if HHVM is involved here too.

Aklapper renamed this task from User:Qian.Nivan cannot login at fawiki with "Exception encountered, of type "Exception" to User:Qian.Nivan cannot login at fawiki due to "Unknown or bad timezone".Jun 16 2016, 9:39 AM
MaxSem added a subscriber: MaxSem.Jun 23 2016, 11:44 PM

Wondering if HHVM is involved here too.

It is, being guilty of behaving like docs say it should, as opposed to what PHP does. In PHP, DateTimeZone constructor throws an exception while its procedural form, timezone_open(), raises a notice. HHVM always throws an exception.

Macro over9000: MY BRAIN EXPLODES

Aklapper triaged this task as Normal priority.Jul 25 2016, 2:50 PM
Reedy added a comment.Jul 25 2016, 3:13 PM

Can't decide if we should close this bug as is (users issue is fixed), and open one for the wider issue

Can't decide if we should close this bug as is (users issue is fixed), and open one for the wider issue

The latter

Change 329039 had a related patch set uploaded (by TTO):
Proper handling of invalid/unknown time zones

https://gerrit.wikimedia.org/r/329039

Wondering if HHVM is involved here too.

It is, being guilty of behaving like docs say it should, as opposed to what PHP does. In PHP, DateTimeZone constructor throws an exception while its procedural form, timezone_open(), raises a notice. HHVM always throws an exception.

It's a poorly written merged documentation page. The docs currently say "Procedural style returns FALSE on failure." which doesn't fit with the "Errors/Exceptions" section. Before they merged them with the OO-style as primary it was clear the procedural version didn't throw exceptions, like most PHP procedural methods.

TTO renamed this task from User:Qian.Nivan cannot login at fawiki due to "Unknown or bad timezone" to Users with unknown or bad timezones can't log in.Dec 25 2016, 11:57 AM
TTO claimed this task.
TTO updated the task description. (Show Details)

Change 329039 merged by jenkins-bot:
Proper handling of invalid/unknown time zones

https://gerrit.wikimedia.org/r/329039

Anomie closed this task as Resolved.Jan 5 2017, 3:39 PM

The fix should be deployed to WMF wikis with 1.29.0-wmf.8.