LanguageConverter makes frequent use of global variables, which can be problematic during initialization, especially for $wgUser (see T235360).
Configuration variables should be injected instead, via LanguageConverterFactory (T226833), using a ServiceOptions object:
- $wgDisableLangConversion
- $wgDisableTitleConversion
- $wgLanguageConverterCacheType
- $wgDisabledVariants
- $wgDefaultLanguageVariant
Variables that depend on the request should be replaced by method parameters. For backwards compatibility, the parameters should initially be optional. Once all known callers have been updated, calling the respective methods without the new parameters should trigger a deprecation warning. In a later release, the parameters should become mandatory. This applies to:
- $wgRequest in getURLVariant(), getHeaderVariant(), findVariantLink()
- $wgUser in getPreferredVariant(), getUserVariant(),
TODO: consider whether the getXxxVariant() methods should be extracted into a separate service, along with getVariants(), getVariantFallback(), validateVariant(), and findVariantLink(). Seems tempting, but it's not immediately obvious whether it would be possible without introducing a cyclic dependency.