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
$cache->delete( $key, 1 );
} else {
wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle(
- function() use ( $cache, $key ) {
+ function () use ( $cache, $key ) {
$cache->delete( $key );
},
__METHOD__
public function touch() {
$id = $this->getId();
if ( $id ) {
- $key = wfMemcKey( 'user-quicktouched', 'id', $id );
- ObjectCache::getMainWANInstance()->touchCheckKey( $key );
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $key = $cache->makeKey( 'user-quicktouched', 'id', $id );
+ $cache->touchCheckKey( $key );
$this->mQuickTouched = null;
}
}
if ( $this->mId ) {
if ( $this->mQuickTouched === null ) {
- $key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $key = $cache->makeKey( 'user-quicktouched', 'id', $this->mId );
$this->mQuickTouched = wfTimestamp( TS_MW, $cache->getCheckKeyTime( $key ) );
}
}
// 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 );
}