return self::$idCacheByName[$name];
}
- $db = ( $flags & self::READ_LATEST )
- ? wfGetDB( DB_MASTER )
- : wfGetDB( DB_SLAVE );
+ list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
+ $db = wfGetDB( $index );
$s = $db->selectRow(
'user',
[ 'user_id' ],
[ 'user_name' => $nt->getText() ],
- __METHOD__
+ __METHOD__,
+ $options
);
if ( $s === false ) {
}
/**
- * Does the string match an anonymous IPv4 address?
+ * Does the string match an anonymous IP address?
*
* This function exists for username validation, in order to reject
* usernames which are similar in form to IP addresses. Strings such
global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
static $defOpt = null;
- if ( !defined( 'MW_PHPUNIT_TEST' ) && $defOpt !== null ) {
- // Disabling this for the unit tests, as they rely on being able to change $wgContLang
- // mid-request and see that change reflected in the return value of this function.
- // Which is insane and would never happen during normal MW operation
+ 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.
return $defOpt;
}
$defOpt = $wgDefaultUserOptions;
// Default language setting
- $defOpt['language'] = $wgContLang->getCode();
+ $defOptLang = $wgContLang->getCode();
+ $defOpt['language'] = $defOptLang;
foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
$defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-$langCode"] = $langCode;
}