51 private $sharedTables;
54 private $localDatabases;
69 $this->dbProvider = $dbProvider;
70 $this->hideUserUtils = $hideUserUtils;
75 if ( !$user->isRegistered() ) {
80 if ( !$wikiId || WikiMap::isCurrentWikiId( $wikiId ) ) {
86 return $this->sharedDB !==
null &&
87 in_array(
'user', $this->sharedTables,
true ) &&
88 in_array( $wikiId, $this->localDatabases,
true );
92 array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = IDBAccessObject::READ_NORMAL
97 $audience = $this->checkAudience( $audience );
98 $db = DBAccessObjectUtils::getDBFromRecency( $this->dbProvider, $flags );
99 $queryBuilder = $db->newSelectQueryBuilder();
101 ->select( [
'user_id',
'user_name' ] )
103 ->where( [
'user_id' => array_map(
'intval', array_keys( $idToName ) ) ] )
106 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
107 $this->hideUserUtils->addFieldToBuilder( $queryBuilder );
110 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
111 foreach ( $res as $row ) {
112 $idToName[$row->user_id] = empty( $row->hu_deleted ) ? $row->user_name :
'';
119 array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = IDBAccessObject::READ_NORMAL
125 $audience = $this->checkAudience( $audience );
126 $db = DBAccessObjectUtils::getDBFromRecency( $this->dbProvider, $flags );
127 $queryBuilder = $db->newSelectQueryBuilder();
129 ->select( [
'user_id',
'user_name' ] )
131 ->where( [
'user_name' => array_map(
'strval', array_keys( $nameToId ) ) ] )
134 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
135 $queryBuilder->andWhere( $this->hideUserUtils->getExpression( $db ) );
138 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
139 foreach ( $res as $row ) {
140 $nameToId[$row->user_name] = (int)$row->user_id;
148class_alias( LocalIdLookup::class,
'LocalIdLookup' );
if(!defined('MW_SETUP_CALLBACK'))
A class containing constants representing the names of configuration variables.
const SharedDB
Name constant for the SharedDB setting, for use with Config::get()
const LocalDatabases
Name constant for the LocalDatabases setting, for use with Config::get()
const SharedTables
Name constant for the SharedTables setting, for use with Config::get()