getId() ) { return false; } // Easy case, we're checking locally if ( $wikiId === null || $wikiId === wfWikiID() ) { return true; } // Assume that shared user tables are set up as described above, if // they're being used at all. return $wgSharedDB !== null && in_array( 'user', $wgSharedTables, true ) && in_array( $wikiId, $wgLocalDatabases, true ); } public function lookupCentralIds( array $idToName, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL ) { if ( !$idToName ) { return []; } $audience = $this->checkAudience( $audience ); list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags ); $db = wfGetDB( $index ); $tables = [ 'user' ]; $fields = [ 'user_id', 'user_name' ]; $where = [ 'user_id' => array_map( 'intval', array_keys( $idToName ) ), ]; $join = []; if ( $audience && !$audience->isAllowed( 'hideuser' ) ) { $tables[] = 'ipblocks'; $join['ipblocks'] = [ 'LEFT JOIN', 'ipb_user=user_id' ]; $fields[] = 'ipb_deleted'; } $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join ); foreach ( $res as $row ) { $idToName[$row->user_id] = empty( $row->ipb_deleted ) ? $row->user_name : ''; } return $idToName; } public function lookupUserNames( array $nameToId, $audience = self::AUDIENCE_PUBLIC, $flags = self::READ_NORMAL ) { if ( !$nameToId ) { return []; } $audience = $this->checkAudience( $audience ); list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags ); $db = wfGetDB( $index ); $tables = [ 'user' ]; $fields = [ 'user_id', 'user_name' ]; $where = [ 'user_name' => array_map( 'strval', array_keys( $nameToId ) ), ]; $join = []; if ( $audience && !$audience->isAllowed( 'hideuser' ) ) { $tables[] = 'ipblocks'; $join['ipblocks'] = [ 'LEFT JOIN', 'ipb_user=user_id' ]; $where[] = 'ipb_deleted = 0 OR ipb_deleted IS NULL'; } $res = $db->select( $tables, $fields, $where, __METHOD__, $options, $join ); foreach ( $res as $row ) { $nameToId[$row->user_name] = (int)$row->user_id; } return $nameToId; } }