The user interface language is not available in the service container, as far as I can tell, neither directly nor as part of some context source. I assume this is because service wiring is supposed to be independent of user configuration or individual request contexts. However, several other services in Wikibase Repository depend on the user language, so I don’t think we can make do without it yet. I suggest we add it to the service wiring file (based on $wgLang), but deprecate the accessor method in WikibaseRepo and create follow-up tasks to remove uses of this service.
Description
Details
Related Objects
- Mentioned In
- rEWLCddbcd79cbb17: Update calls to getUserLanguage
T279415: Remove calls to deprecated WikibaseRepo::getUserLanguage
T268600: Implement services through MediaWikiServices
T277577: Move WikibaseRepo MessageParameterFormatter to service container - Mentioned Here
- T279415: Remove calls to deprecated WikibaseRepo::getUserLanguage
T218555: Provide access to WebRequest and associated information via a service object
Event Timeline
As far as I’m aware, the two main sources of the user language (assuming you don’t have access to an IContextSource where you can call getLanguage()) are global $wgLang and RequestContext::getMain()->getLanguage(). (Which ultimately amounts to the same thing – see StubUserLang::_newObject().) CirrusSearch’s SearchConfig.php puts it like this:
/** * Get user's language * @return string User's language code */ public function getUserLanguage() { // I suppose using $wgLang would've been more evil than this, but // only marginally so. Find some real context to use here. return RequestContext::getMain()->getLanguage()->getCode(); }
For our service wiring, I suggest we use $wgLang, which should be easier to mock in the unit test for this service wiring.
See also T218555: Provide access to WebRequest and associated information via a service object for some discussion of the user language (though it’s not the main focus of the discussion).
Change 676423 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/WikibaseCirrusSearch@master] Update calls to getUserLanguage
Change 676422 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/Wikibase@master] Move WikibaseRepo UserLanguage to service container
Change 676428 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/WikibaseLexeme@master] Update calls to getUserLanguage
Change 676432 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/WikibaseLexemeCirrusSearch@master] Update calls to getUserLanguage
Change 676433 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/WikibaseMediaInfo@master] Update calls to getUserLanguage
Change 676434 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/WikibaseQualityConstraints@master] Update calls to getUserLanguage
Change 677288 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):
[mediawiki/extensions/WikibaseLexeme@master] Pass down MediaWiki services
Change 676422 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move WikibaseRepo UserLanguage to service container
Change 676428 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Update calls to getUserLanguage
Change 676423 merged by jenkins-bot:
[mediawiki/extensions/WikibaseCirrusSearch@master] Update calls to getUserLanguage
Change 676432 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexemeCirrusSearch@master] Update calls to getUserLanguage
Change 676434 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Update calls to getUserLanguage
Change 677288 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Pass down MediaWiki services
Change 676433 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Update calls to getUserLanguage