Page MenuHomePhabricator

$wgDefaultUserOptions['date'] = 'dmyts' causes MWException error when accessing settings
Open, MediumPublic

Description

Author: floeff

Description:
In recent snapshots, the setting

$wgDefaultUserOptions['date'] = 'dmyts';

causes an MWException error when accessing settings, at least in certain languages. For 'de' it seems to work, for 'en' and 'fr' it produces an error. Resetting it to

$wgDefaultUserOptions['date'] = 'dmy';
(i.e. without "ts")

seems to cure the problem.


Version: 1.21.x
Severity: minor

Details

Reference
bz42355

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:52 AM
bzimport set Reference to bz42355.
bzimport added a subscriber: Unknown Object (MLST).

floeff wrote:

In 1.21wmf6 same issue, but this time 'dmy', 'mdy' and 'ymd' also don't work. Only 'ISO 8601' seems to work.

Error message is: Global default 'dmyts' is invalid for field date
thrown in Preferences::getPreferences

Looks like expected, because it is not possible to use a default date preference, which is not defined for the language.

'dmyts' is only known by language = 'de', so other languages cannot used with that.

(In reply to Umherirrender from comment #2)

Error message is: Global default 'dmyts' is invalid for field date
thrown in Preferences::getPreferences

Looks like expected, because it is not possible to use a default date
preference, which is not defined for the language.

'dmyts' is only known by language = 'de', so other languages cannot used
with that.

I think this is valid reasoning. Unless there is an objection, this can be set to WORKSFORME.

Also apparently a regression - bug 19237

I think this is valid reasoning. Unless there is an objection, this can be
set to WORKSFORME.

I disagree

Set:

$wgLanguageCode = "fa";
$wgDefaultUserOptions['date'] = 'hebrew';

Go to Special:Preferences. Everything is fine.

Keep the same settings. Go to Special:Preferences?uselang=en (or switch your user user language to en). Exception is thrown.

I consider that behaviour to be pretty broken. Not sure what the fix is. Maybe date preferences should be both the content language options + the user language options (?)

(In reply to Bawolff (Brian Wolff) from comment #6)

I disagree

Set:

$wgLanguageCode = "fa";
$wgDefaultUserOptions['date'] = 'hebrew';

Go to Special:Preferences. Everything is fine.

Keep the same settings. Go to Special:Preferences?uselang=en (or switch your
user user language to en). Exception is thrown.

I consider that behaviour to be pretty broken. Not sure what the fix is.
Maybe date preferences should be both the content language options + the
user language options (?)

Yeah definitely agree with you there.

The solution is to have a fallback method for finding the default. However, it seems the code already has such a mechanism (see the code changes both you and I linked), but for some reason that is not working anymore.

(In reply to Tyler Romeo from comment #7)

(In reply to Bawolff (Brian Wolff) from comment #6)

I disagree

Set:

$wgLanguageCode = "fa";
$wgDefaultUserOptions['date'] = 'hebrew';

Go to Special:Preferences. Everything is fine.

Keep the same settings. Go to Special:Preferences?uselang=en (or switch your
user user language to en). Exception is thrown.

I consider that behaviour to be pretty broken. Not sure what the fix is.
Maybe date preferences should be both the content language options + the
user language options (?)

Yeah definitely agree with you there.

The solution is to have a fallback method for finding the default. However,
it seems the code already has such a mechanism (see the code changes both
you and I linked), but for some reason that is not working anymore.

Its because that code is changing the $wgDefaultUserOptions, but the other code is using User::getDefaultOptions(), which caches a modified $wgDefaultUserOptions in a static variable.

Modifying $wgDefaultUserOptions in Preferences::getDateOptions() seems really really hacky to me. This should probably be changed to happen in User::getDefaultOptions(), and possibly also Preferences::getDateOptions() should be using content language, or maybe content language + user language combined. Definitely should not use only user language.