$req = $this->getURLVariant();
- if ( $wgUser->isLoggedIn() && !$req ) {
+ if ( $wgUser->isSafeToLoad() && $wgUser->isLoggedIn() && !$req ) {
$req = $this->getUserVariant();
} elseif ( !$req ) {
$req = $this->getHeaderVariant();
// Get language variant preference from logged in users
// Don't call this on stub objects because that causes infinite
// recursion during initialisation
+ if ( !$wgUser->isSafeToLoad() ) {
+ return false;
+ }
if ( $wgUser->isLoggedIn() ) {
if ( $this->mMainLanguageCode == $wgContLang->getCode() ) {
$ret = $wgUser->getOption( 'variant' );
$first = false;
continue;
}
- $mappings = explode( '}-', $block, 2 );
- $stripped = str_replace( [ "'", '"', '*', '#' ], '', $mappings[0] );
+ $mappings = explode( '}-', $block, 2 )[0];
+ $stripped = str_replace( [ "'", '"', '*', '#' ], '', $mappings );
$table = StringUtils::explode( ';', $stripped );
foreach ( $table as $t ) {
$m = explode( '=>', $t, 3 );
// -{zh-hans:<span style="font-size:120%;">xxx</span>;zh-hant:\
// <span style="font-size:120%;">yyy</span>;}-
// we should split it as:
- // array(
+ // [
// [0] => 'zh-hans:<span style="font-size:120%;">xxx</span>'
// [1] => 'zh-hant:<span style="font-size:120%;">yyy</span>'
// [2] => ''
- // )
+ // ]
$pat = '/;\s*(?=';
foreach ( $this->mVariants as $variant ) {
// zh-hans:xxx;zh-hant:yyy