41 if ( !$user->
getId() ) {
46 if ( $wikiId ===
null || WikiMap::isCurrentWikiId( $wikiId ) ) {
58 array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
65 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
69 $fields = [
'user_id',
'user_name' ];
71 'user_id' => array_map(
'intval', array_keys( $idToName ) ),
74 if ( $audience && !MediaWikiServices::getInstance()
76 ->userHasRight( $audience,
'hideuser' )
78 $tables[] =
'ipblocks';
79 $join[
'ipblocks'] = [
'LEFT JOIN',
'ipb_user=user_id' ];
80 $fields[] =
'ipb_deleted';
83 $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join );
84 foreach (
$res as $row ) {
85 $idToName[$row->user_id] = empty( $row->ipb_deleted ) ? $row->user_name :
'';
92 array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL
99 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
102 $tables = [
'user' ];
103 $fields = [
'user_id',
'user_name' ];
105 'user_name' => array_map(
'strval', array_keys( $nameToId ) ),
108 if ( $audience && !MediaWikiServices::getInstance()
110 ->userHasRight( $audience,
'hideuser' )
112 $tables[] =
'ipblocks';
113 $join[
'ipblocks'] = [
'LEFT JOIN',
'ipb_user=user_id' ];
114 $where[] =
'ipb_deleted = 0 OR ipb_deleted IS NULL';
117 $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join );
118 foreach (
$res as $row ) {
119 $nameToId[$row->user_name] = (int)$row->user_id;
$wgSharedDB
Shared database for multiple wikis.
string[] $wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
The CentralIdLookup service allows for connecting local users with cluster-wide IDs.
checkAudience( $audience)
Check that the "audience" parameter is valid.
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.
isAttached(User $user, $wikiId=null)
Check that a User is attached on the specified wiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getId()
Get the user's ID.