58 $this->sharedDB = $config->
get(
'SharedDB' );
59 $this->sharedTables = $config->
get(
'SharedTables' );
60 $this->localDatabases = $config->
get(
'LocalDatabases' );
61 $this->loadBalancer = $loadBalancer;
66 if ( !$user->getId() ) {
71 if ( !$wikiId || WikiMap::isCurrentWikiId( $wikiId ) ) {
77 return $this->sharedDB !==
null &&
78 in_array(
'user', $this->sharedTables,
true ) &&
79 in_array( $wikiId, $this->localDatabases,
true );
83 array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
88 $audience = $this->checkAudience( $audience );
89 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
90 $db = $this->loadBalancer->getConnectionRef( $index );
93 $fields = [
'user_id',
'user_name' ];
95 'user_id' => array_map(
'intval', array_keys( $idToName ) ),
98 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
99 $tables[] =
'ipblocks';
100 $join[
'ipblocks'] = [
'LEFT JOIN',
'ipb_user=user_id' ];
101 $fields[] =
'ipb_deleted';
104 $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join );
105 foreach (
$res as $row ) {
106 $idToName[$row->user_id] = empty( $row->ipb_deleted ) ? $row->user_name :
'';
113 array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
119 $audience = $this->checkAudience( $audience );
120 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
121 $db = $this->loadBalancer->getConnectionRef( $index );
123 $tables = [
'user' ];
124 $fields = [
'user_id',
'user_name' ];
126 'user_name' => array_map(
'strval', array_keys( $nameToId ) ),
129 if ( $audience && !$audience->isAllowed(
'hideuser' ) ) {
130 $tables[] =
'ipblocks';
131 $join[
'ipblocks'] = [
'LEFT JOIN',
'ipb_user=user_id' ];
132 $where[] =
'ipb_deleted = 0 OR ipb_deleted IS NULL';
135 $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join );
136 foreach (
$res as $row ) {
137 $nameToId[$row->user_name] = (int)$row->user_id;
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
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.
ILoadBalancer $loadBalancer
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".