X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fuser%2FUser.php;h=d6d4db25f32cf5fb0b6a04a05f485d2f015c0aff;hp=5e57a188913c20b08b6e9b6373ed5033d234507a;hb=fe94275c8fcfc248a5eae857dde7c5772d993ab5;hpb=d9327f9a57213488ed35b6a5dd532feb4f70125f diff --git a/includes/user/User.php b/includes/user/User.php index 5e57a18891..d6d4db25f3 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -986,13 +986,13 @@ class User implements IDBAccessObject, UserIdentity { * @return bool */ public static function isValidUserName( $name ) { - global $wgContLang, $wgMaxNameChars; + global $wgMaxNameChars; if ( $name == '' || self::isIP( $name ) || strpos( $name, '/' ) !== false || strlen( $name ) > $wgMaxNameChars - || $name != $wgContLang->ucfirst( $name ) + || $name != MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $name ) ) { return false; } @@ -1010,10 +1010,10 @@ class User implements IDBAccessObject, UserIdentity { // Should these be merged into the title char list? $unicodeBlacklist = '/[' . '\x{0080}-\x{009f}' . # iso-8859-1 control chars - '\x{00a0}' . # non-breaking space + '\x{00a0}' . # non-breaking space '\x{2000}-\x{200f}' . # various whitespace '\x{2028}-\x{202f}' . # breaks and control chars - '\x{3000}' . # ideographic space + '\x{3000}' . # ideographic space '\x{e000}-\x{f8ff}' . # private use ']/u'; if ( preg_match( $unicodeBlacklist, $name ) ) { @@ -1228,8 +1228,7 @@ class User implements IDBAccessObject, UserIdentity { */ public static function getCanonicalName( $name, $validate = 'valid' ) { // Force usernames to capital - global $wgContLang; - $name = $wgContLang->ucfirst( $name ); + $name = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $name ); # Reject names containing '#'; these will be cleaned up # with title normalisation, but then it's too late to @@ -1761,24 +1760,29 @@ class User implements IDBAccessObject, UserIdentity { * @return array Array of String options */ public static function getDefaultOptions() { - global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin; + global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgDefaultSkin; static $defOpt = null; static $defOptLang = null; - 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. return $defOpt; } $defOpt = $wgDefaultUserOptions; // Default language setting - $defOptLang = $wgContLang->getCode(); + $defOptLang = $contLang->getCode(); $defOpt['language'] = $defOptLang; foreach ( LanguageConverter::$languagesWithVariants as $langCode ) { - $defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-$langCode"] = $langCode; + if ( $langCode === $contLang->getCode() ) { + $defOpt['variant'] = $langCode; + } else { + $defOpt["variant-$langCode"] = $langCode; + } } // NOTE: don't use SearchEngineConfig::getSearchableNamespaces here, @@ -5453,8 +5457,6 @@ class User implements IDBAccessObject, UserIdentity { * @param array|null $data Rows for the current user out of the user_properties table */ protected function loadOptions( $data = null ) { - global $wgContLang; - $this->load(); if ( $this->mOptionsLoaded ) { @@ -5468,7 +5470,7 @@ class User implements IDBAccessObject, UserIdentity { // There's no need to do it for logged-in users: they can set preferences, // and handling of page content is done by $pageLang->getPreferredVariant() and such, // so don't override user's choice (especially when the user chooses site default). - $variant = $wgContLang->getDefaultVariant(); + $variant = MediaWikiServices::getInstance()->getContentLanguage()->getDefaultVariant(); $this->mOptions['variant'] = $variant; $this->mOptions['language'] = $variant; $this->mOptionsLoaded = true;