/**
* @since 1.27
- * @param string $wikiId
+ * @param string $dbDomain
* @param int $userId
*/
- public static function purge( $wikiId, $userId ) {
+ public static function purge( $dbDomain, $userId ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
- $key = $cache->makeGlobalKey( 'user', 'id', $wikiId, $userId );
+ $key = $cache->makeGlobalKey( 'user', 'id', $dbDomain, $userId );
$cache->delete( $key );
}
* @param int|null $userId User ID, if known
* @param string|null $userName User name, if known
* @param int|null $actorId Actor ID, if known
- * @param bool|string $wikiId remote wiki to which the User/Actor ID applies, or false if none
+ * @param bool|string $dbDomain remote wiki to which the User/Actor ID applies, or false if none
* @return User
*/
- public static function newFromAnyId( $userId, $userName, $actorId, $wikiId = false ) {
+ public static function newFromAnyId( $userId, $userName, $actorId, $dbDomain = false ) {
global $wgActorTableSchemaMigrationStage;
// Stop-gap solution for the problem described in T222212.
// Force the User ID and Actor ID to zero for users loaded from the database
// of another wiki, to prevent subtle data corruption and confusing failure modes.
- if ( $wikiId !== false ) {
+ if ( $dbDomain !== false ) {
$userId = 0;
$actorId = 0;
}
$user = $session->getUser();
if ( $user->isLoggedIn() ) {
$this->loadFromUserObject( $user );
- if ( $user->getBlock() ) {
- // If this user is autoblocked, set a cookie to track the block. This has to be done on
- // every session load, because an autoblocked editor might not edit again from the same
- // IP address after being blocked.
- MediaWikiServices::getInstance()->getBlockManager()->trackBlockWithCookie( $this );
- }
+
+ // If this user is autoblocked, set a cookie to track the block. This has to be done on
+ // every session load, because an autoblocked editor might not edit again from the same
+ // IP address after being blocked.
+ MediaWikiServices::getInstance()->getBlockManager()->trackBlockWithCookie( $this );
// Other code expects these to be set in the session, so set them.
$session->set( 'wsUserID', $this->getId() );
if ( $count === null ) {
// it has not been initialized. do so.
- $count = $this->initEditCountInternal();
+ $count = $this->initEditCountInternal( $dbr );
}
$this->mEditCount = $count;
}
/**
* Initialize user_editcount from data out of the revision table
*
- * This method should not be called outside User/UserEditCountUpdate
- *
+ * @internal This method should not be called outside User/UserEditCountUpdate
+ * @param IDatabase $dbr Replica database
* @return int Number of edits
*/
- public function initEditCountInternal() {
+ public function initEditCountInternal( IDatabase $dbr ) {
// Pull from a replica DB to be less cruel to servers
// Accuracy isn't the point anyway here
- $dbr = wfGetDB( DB_REPLICA );
$actorWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $this );
$count = (int)$dbr->selectField(
[ 'revision' ] + $actorWhere['tables'],