52 private $sharedTables;
55 private $localDatabases;
70 $this->dbProvider = $dbProvider;
71 $this->hideUserUtils = $hideUserUtils;
76 if ( !$user->isRegistered() ) {
81 if ( !$wikiId || WikiMap::isCurrentWikiId( $wikiId ) ) {
87 return $this->sharedDB !==
null &&
88 in_array(
'user', $this->sharedTables,
true ) &&
89 in_array( $wikiId, $this->localDatabases,
true );
93 array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
98 $audience = $this->checkAudience( $audience );
99 [ $index, $options ] = DBAccessObjectUtils::getDBOptions( $flags );
100 $db = DBAccessObjectUtils::getDBFromIndex( $this->dbProvider, $index );
101 $queryBuilder = $db->newSelectQueryBuilder();
103 ->select( [
'user_id',
'user_name' ] )
105 ->where( [
'user_id' => array_map(
'intval', array_keys( $idToName ) ) ] )
106 ->options( $options );
108 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
109 $this->hideUserUtils->addFieldToBuilder( $queryBuilder );
112 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
113 foreach ( $res as $row ) {
114 $idToName[$row->user_id] = empty( $row->hu_deleted ) ? $row->user_name :
'';
121 array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
127 $audience = $this->checkAudience( $audience );
128 [ $index, $options ] = DBAccessObjectUtils::getDBOptions( $flags );
129 $db = DBAccessObjectUtils::getDBFromIndex( $this->dbProvider, $index );
130 $queryBuilder = $db->newSelectQueryBuilder();
132 ->select( [
'user_id',
'user_name' ] )
134 ->where( [
'user_name' => array_map(
'strval', array_keys( $nameToId ) ) ] )
135 ->options( $options );
137 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
138 $queryBuilder->andWhere( $this->hideUserUtils->getExpression( $db ) );
141 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
142 foreach ( $res as $row ) {
143 $nameToId[$row->user_name] = (int)$row->user_id;
154class_alias( LocalIdLookup::class,
'LocalIdLookup' );
if(!defined('MW_SETUP_CALLBACK'))
Helper class for DAO classes.
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()