- if ( $defOpt !== null && $defOptLang === $wgContLang->getCode() ) {
- // $wgContLang does not change (and should not change) mid-request,
- // but the unit tests change it anyway, and expect this method to
- // return values relevant to the current $wgContLang.
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ if ( $defOpt !== null && $defOptLang === $contLang->getCode() ) {
+ // The content language does not change (and should not change) mid-request, but the
+ // unit tests change it anyway, and expect this method to return values relevant to the
+ // current content language.