Make Language::hasVariant() more strict
authorC. Scott Ananian <cscott@cscott.net>
Fri, 19 Oct 2018 19:00:52 +0000 (15:00 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Mon, 22 Oct 2018 20:35:26 +0000 (16:35 -0400)
commitfcbde8ae4ec6890eca9cebcce6db3fc22c8a20d8
treeccf3597eef28e7569f49f73f9c9d57f97883b4f3
parentce5411df3c0a0ecbc651c72a297506b2e0f31e42
Make Language::hasVariant() more strict

In d59f27aeab08b171e5ab6a081e763a4cad0bca04 we made
LanguageConverter::validateVariant() try harder to convert a variant
into an acceptable MediaWiki-internal form, looking at deprecated
codes and BCP 47 aliases.  However, this misled Language::hasVariant()
into thinking that bogus names (like all-uppercase strings) were
acceptable variant names, which then led exceptions when they were
passed to the various conversion methods.

This is a belt-and-suspenders patch for T207433 -- in that case we
shouldn't have created a Language object with code 'sr-cyrl' in the
first place, but once one was created we shouldn't have tried to
ask LanguageSr to convert texts to 'sr-cyrl'.  The latter problem
is fixed by this patch.

Bug: T207433
Change-Id: Id993bc7989144b5031a551662e8e492bd23f698a
languages/Language.php
languages/LanguageConverter.php
tests/phpunit/languages/LanguageTest.php
tests/phpunit/languages/classes/LanguageSrTest.php