Last modified: 2014-10-11 14:56:27 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T39459, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 37459 - Don't try to add labels in non-existing languages: restrict to Language::isKnownLanguageTag
Don't try to add labels in non-existing languages: restrict to Language::isKn...
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
unspecified
All All
: Normal major with 2 votes (vote)
: ---
Assigned To: Wikidata bugs
u=dev c=backend p=0
: i18n, need-volunteer
: 46455 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-11 11:31 UTC by Nikola Smolenski
Modified: 2014-10-11 14:56 UTC (History)
11 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Nikola Smolenski 2012-06-11 11:31:07 UTC
If you go to a page and specify an non-existing content language http://wikidata-test-repo.wikimedia.de/wiki/Data:Q2?uselang=xyzzy , the interface will offer you to enter the label in the language. This will fail with "Unrecognized value for parameter 'language': xyzzy" error, but I believe the interface should not even offer the possibility to enter the label, perhaps displaying an error right away.
Comment 1 jeblad 2012-06-11 20:16:16 UTC
It should not be possible to set an illegal code through the user interface, but it can be done by directly manipulating the url.

Normal "page" behavior is to fall back and en up with English messages if the language is unknown. This makes it seem like the site uses English user language when this happens, but the user language code is wrong for the whole page.

It seems likely that either the language code  for the user language should do a similar fall back, if the code itself is illegal (ie. the bug scenario), or this should be solved through the normal language fall back when that is implemented, and then only if the code itself is legal.

Note that the language fall back mechanism in Wikidata might only be available if the user is logged in.
Comment 2 denny vrandecic 2012-06-20 22:52:12 UTC
The official language switcher will not be through the URL query parameter, but through a widget to change the language. Tinkering with the uselang query parameter is something that should be captured at the core, not in the extension, if at all, I think. Not sure.
Comment 3 Nikola Smolenski 2012-06-21 06:19:19 UTC
How will the language switcher change the language if not through the URL? Through a cookie? I don't think that's a good idea, for multiple reasons.

Anyway, the extension doesn't need to tinker with uselang, it could simply write an error message, or fallback to English like the core.
Comment 4 denny vrandecic 2012-06-21 11:14:01 UTC
OK, this sounds like a good solution.
Comment 5 jeblad 2012-08-24 16:36:05 UTC
This should be fixed in the ULS. We could possibly add (or ask if it is added) a test for languages that either is lacking message files (Language::isValidBuiltInCode), or a more general test of defined codes (Language::isValidAndDefined). Now the ULS seems to use RequestContext::sanitizeLangCode which calls Language::isValidCode, which only checks if the code is well-formed. We probably need something that checks if the language in fact exist. This is at line 93 in UniversalLanguageSelector.php and at line 217 in RequestContext.php.

The easiest seems to me to add a config to make the ULS use Language::isValidBuiltInCode instead of Language::isValidCode by adding additional sinitizing in UniversalLanguageSelector::getLanguage and skipping the call to RequestContext::sanitizeLangCode.
Comment 6 Nemo 2013-04-05 08:50:52 UTC
(In reply to comment #5)
> This should be fixed in the ULS.

ULS doesn't use uselang.

(In reply to comment #3)
> Anyway, the extension doesn't need to tinker with uselang, it could simply
> write an error message, or fallback to English like the core.

See bug 39623 comment 9 for validation, but this can likely end up being a duplicate of bug 46455.
Comment 7 Nikola Smolenski 2013-04-05 09:05:02 UTC
I'd rather say that bug 46455 is a duplicate of this bug ;) But yes, they are similar: 46455 is about recognized but unwanted codes, this one is about completely unrecognized codes; otherwise to me they seem the same.
Comment 8 Siebrand Mazeland 2013-04-05 09:12:07 UTC
I think that allowing any valid BCP 47 might suffice. Adding Niklas to CC for an opinion.
Comment 9 Niklas Laxström 2013-04-06 16:14:28 UTC
I'd restrict data input to Language::isKnownLanguageTag so that we can at least display the name... otherwise we can get all kinds of weird stuff. We can extend our known language tag coverage by resurrecting https://gerrit.wikimedia.org/r/#/c/11829/ - perhaps as an extension.

With regards to ULS, interface language selection should be limited to supported languages (Language::isSupportedLanguage) for setlang. uselang should still be able to use pretty much anything (Language::isValidCode).
Comment 10 Nemo 2013-04-07 00:30:20 UTC
*** Bug 46455 has been marked as a duplicate of this bug. ***
Comment 11 Lydia Pintscher 2013-10-08 13:55:46 UTC
So is this something that needs to be done in Wikibase actually? Or Core?
Comment 12 Nemo 2013-10-08 15:13:47 UTC
(In reply to comment #11)
> So is this something that needs to be done in Wikibase actually? Or Core?

Wikibase. Core already offers the language code validation function you need, which is mentioned by Niklas above and in the summary.
Comment 13 Nemo 2014-05-01 08:35:51 UTC
Akkakk produced helpful stats and lists of labels, descriptions and aliases in invalid language codes (+de-formal which is another story, bug 49024). Over 400 thousands... They'll be fixed by bots, but this warrants a "major".

https://www.wikidata.org/w/index.php?title=Wikidata:Project_chat&oldid=124218030#.27als.27.2F.27gsw.27.3F_.27de-formal.27.3F
https://www.wikidata.org/wiki/User:Akkakk/issues/deprecated-languages
Comment 14 Nemo 2014-10-07 10:56:37 UTC
Related: https://gerrit.wikimedia.org/r/#/c/164725/3
I asked there to explain better here.
Comment 15 Marius Hoch 2014-10-09 19:37:56 UTC
(In reply to Nemo from comment #14)
> Related: https://gerrit.wikimedia.org/r/#/c/164725/3
> I asked there to explain better here.

This bug still exists: The patch you linked only affects languages referenced via the Babel parserfunction on user pages.
Comment 16 Nemo 2014-10-10 12:00:28 UTC
(In reply to Marius Hoch from comment #15)
> This bug still exists: The patch you linked only affects languages
> referenced via the Babel parserfunction on user pages.

Ah. So that was a consequence of (ab)using internal Babel functions? Can you please also file a bug against Babel requesting an API to provide the information that (at least) Wikidata needs? Thanks.
Comment 17 Marius Hoch 2014-10-11 14:53:36 UTC
(In reply to Nemo from comment #16)
> (In reply to Marius Hoch from comment #15)
> > This bug still exists: The patch you linked only affects languages
> > referenced via the Babel parserfunction on user pages.
> 
> Ah. So that was a consequence of (ab)using internal Babel functions? Can you
> please also file a bug against Babel requesting an API to provide the
> information that (at least) Wikidata needs? Thanks.

No, I don't think Babel should have such an API: The API it has is fine and anything we do beyond that doesn't belong into Babel.
Comment 18 Nemo 2014-10-11 14:56:27 UTC
(In reply to Marius Hoch from comment #17)
> No, I don't think Babel should have such an API: The API it has is fine and
> anything we do beyond that doesn't belong into Babel.

Oh. 3 our of 3 persons I asked so far thought the opposite. You may to want to join https://www.mediawiki.org/wiki/Thread:Extension_talk:Babel/Babel_API as we're off topic here.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links