40 private $loadBalancer;
46 private $sharedTables;
49 private $localDatabases;
59 $this->sharedDB = $config->
get( MainConfigNames::SharedDB );
60 $this->sharedTables = $config->
get( MainConfigNames::SharedTables );
61 $this->localDatabases = $config->
get( MainConfigNames::LocalDatabases );
62 $this->loadBalancer = $loadBalancer;
67 if ( !$user->isRegistered() ) {
72 if ( !$wikiId || WikiMap::isCurrentWikiId( $wikiId ) ) {
78 return $this->sharedDB !==
null &&
79 in_array(
'user', $this->sharedTables,
true ) &&
80 in_array( $wikiId, $this->localDatabases,
true );
84 array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
89 $audience = $this->checkAudience( $audience );
90 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
91 $db = $this->loadBalancer->getConnectionRef( $index );
94 $fields = [
'user_id',
'user_name' ];
96 'user_id' => array_map(
'intval', array_keys( $idToName ) ),
99 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
100 $tables[] =
'ipblocks';
101 $join[
'ipblocks'] = [
'LEFT JOIN',
'ipb_user=user_id' ];
102 $fields[] =
'ipb_deleted';
105 $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join );
106 foreach (
$res as $row ) {
107 $idToName[$row->user_id] = empty( $row->ipb_deleted ) ? $row->user_name :
'';
114 array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
120 $audience = $this->checkAudience( $audience );
121 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
122 $db = $this->loadBalancer->getConnectionRef( $index );
124 $tables = [
'user' ];
125 $fields = [
'user_id',
'user_name' ];
127 'user_name' => array_map(
'strval', array_keys( $nameToId ) ),
130 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
131 $tables[] =
'ipblocks';
132 $join[
'ipblocks'] = [
'LEFT JOIN',
'ipb_user=user_id' ];
133 $where[] =
'ipb_deleted = 0 OR ipb_deleted IS NULL';
136 $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join );
137 foreach (
$res as $row ) {
138 $nameToId[$row->user_name] = (int)$row->user_id;
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
The CentralIdLookup service allows for connecting local users with cluster-wide IDs.
A CentralIdLookup provider that just uses local IDs.
lookupUserNames(array $nameToId, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given (local) user names, return the central IDs.
lookupCentralIds(array $idToName, $audience=self::AUDIENCE_PUBLIC, $flags=self::READ_NORMAL)
Given central user IDs, return the (local) user names.
__construct(Config $config, ILoadBalancer $loadBalancer)
isAttached(UserIdentity $user, $wikiId=UserIdentity::LOCAL)
Check that a user is attached on the specified wiki.
A class containing constants representing the names of configuration variables.
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".