/** @var integer User::READ_* constant bitfield used to load data */
protected $queryFlagsUsed = self::READ_NORMAL;
- /** @var string Indicates type of block (used for eventlogging)
- * Permitted values: 'cookie-block', 'proxy-block', 'openproxy-block', 'xff-block',
- * 'config-block'
- */
- public $blockTrigger = false;
-
public static $idCacheByName = [];
/**
return null;
}
- $fields = self::selectFields();
-
- $dbw = wfGetDB( DB_MASTER );
- $row = $dbw->selectRow(
+ $dbr = wfGetDB( DB_REPLICA );
+ $row = $dbr->selectRow(
'user',
- $fields,
+ self::selectFields(),
[ 'user_name' => $name ],
__METHOD__
);
+ if ( !$row ) {
+ // Try the master database...
+ $dbw = wfGetDB( DB_MASTER );
+ $row = $dbw->selectRow(
+ 'user',
+ self::selectFields(),
+ [ 'user_name' => $name ],
+ __METHOD__
+ );
+ }
+
if ( !$row ) {
// No user. Create it?
- return $options['create'] ? self::createNew( $name, [ 'token' => self::INVALID_TOKEN ] ) : null;
+ return $options['create']
+ ? self::createNew( $name, [ 'token' => self::INVALID_TOKEN ] )
+ : null;
}
+
$user = self::newFromRow( $row );
// A user is considered to exist as a non-system user if it can
'address' => $ip,
'systemBlock' => 'proxy',
] );
- $this->blockTrigger = 'proxy-block';
} elseif ( $this->isAnon() && $this->isDnsBlacklisted( $ip ) ) {
$block = new Block( [
'byText' => wfMessage( 'sorbs' )->text(),
'address' => $ip,
'systemBlock' => 'dnsbl',
] );
- $this->blockTrigger = 'openproxy-block';
}
}
# Mangle the reason to alert the user that the block
# originated from matching the X-Forwarded-For header.
$block->mReason = wfMessage( 'xffblockreason', $block->mReason )->text();
- $this->blockTrigger = 'xff-block';
}
}
'anonOnly' => true,
'systemBlock' => 'wgSoftBlockRanges',
] );
- $this->blockTrigger = 'config-block';
}
if ( $block instanceof Block ) {
$this->mBlockedby = '';
$this->mHideName = 0;
$this->mAllowUsertalk = false;
- $this->blockTrigger = false;
}
// Avoid PHP 7.1 warning of passing $this by reference
$useBlockCookie = ( $config->get( 'CookieSetOnAutoblock' ) === true );
if ( $blockIsValid && $useBlockCookie ) {
// Use the block.
- $this->blockTrigger = 'cookie-block';
return $tmpBlock;
} else {
// If the block is not valid, remove the cookie.
$cache->delete( $key, 1 );
} else {
wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle(
- function() use ( $cache, $key ) {
+ function () use ( $cache, $key ) {
$cache->delete( $key );
},
__METHOD__
}
// Try to update the DB post-send and only if needed...
- DeferredUpdates::addCallableUpdate( function() use ( $title, $oldid ) {
+ DeferredUpdates::addCallableUpdate( function () use ( $title, $oldid ) {
if ( !$this->getNewtalk() ) {
return; // no notifications to clear
}
}
$title = UserGroupMembership::getGroupPage( $group );
if ( $title ) {
- return Linker::link( $title, htmlspecialchars( $text ) );
+ return MediaWikiServices::getInstance()
+ ->getLinkRenderer()->makeLink( $title, $text );
} else {
return htmlspecialchars( $text );
}