$parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
if ( count( $parts ) < 2 ) {
$name = trim( $username );
- $wikiId = '';
+ $dbDomain = '';
} else {
- list( $name, $wikiId ) = array_map( 'trim', $parts );
+ list( $name, $dbDomain ) = array_map( 'trim', $parts );
- if ( WikiMap::isCurrentWikiId( $wikiId ) ) {
- $wikiId = '';
+ if ( WikiMap::isCurrentWikiId( $dbDomain ) ) {
+ $dbDomain = '';
} else {
if ( $writing && !$this->getUser()->isAllowed( 'userrights-interwiki' ) ) {
return Status::newFatal( 'userrights-no-interwiki' );
}
- if ( !UserRightsProxy::validDatabase( $wikiId ) ) {
- return Status::newFatal( 'userrights-nodatabase', $wikiId );
+ if ( !UserRightsProxy::validDatabase( $dbDomain ) ) {
+ return Status::newFatal( 'userrights-nodatabase', $dbDomain );
}
}
}
// We'll do a lookup for the name internally.
$id = intval( substr( $name, 1 ) );
- if ( $wikiId == '' ) {
+ if ( $dbDomain == '' ) {
$name = User::whoIs( $id );
} else {
- $name = UserRightsProxy::whoIs( $wikiId, $id );
+ $name = UserRightsProxy::whoIs( $dbDomain, $id );
}
if ( !$name ) {
}
}
- if ( $wikiId == '' ) {
+ if ( $dbDomain == '' ) {
$user = User::newFromName( $name );
} else {
- $user = UserRightsProxy::newFromName( $wikiId, $name );
+ $user = UserRightsProxy::newFromName( $dbDomain, $name );
}
if ( !$user || $user->isAnon() ) {
/**
* @since 1.27
- * @param string $wikiId
+ * @param string $dbDomain
* @param int $userId
*/
- public static function purge( $wikiId, $userId ) {
+ public static function purge( $dbDomain, $userId ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
- $key = $cache->makeGlobalKey( 'user', 'id', $wikiId, $userId );
+ $key = $cache->makeGlobalKey( 'user', 'id', $dbDomain, $userId );
$cache->delete( $key );
}
* @param int|null $userId User ID, if known
* @param string|null $userName User name, if known
* @param int|null $actorId Actor ID, if known
- * @param bool|string $wikiId remote wiki to which the User/Actor ID applies, or false if none
+ * @param bool|string $dbDomain remote wiki to which the User/Actor ID applies, or false if none
* @return User
*/
- public static function newFromAnyId( $userId, $userName, $actorId, $wikiId = false ) {
+ public static function newFromAnyId( $userId, $userName, $actorId, $dbDomain = false ) {
global $wgActorTableSchemaMigrationStage;
// Stop-gap solution for the problem described in T222212.
// Force the User ID and Actor ID to zero for users loaded from the database
// of another wiki, to prevent subtle data corruption and confusing failure modes.
- if ( $wikiId !== false ) {
+ if ( $dbDomain !== false ) {
$userId = 0;
$actorId = 0;
}
/** @var IDatabase */
private $db;
/** @var string */
- private $wikiId;
+ private $dbDomain;
/** @var string */
private $name;
/** @var int */
* @see newFromId()
* @see newFromName()
* @param IDatabase $db Db connection
- * @param string $wikiId Database name
+ * @param string $dbDomain Database name
* @param string $name User name
* @param int $id User ID
*/
- private function __construct( $db, $wikiId, $name, $id ) {
+ private function __construct( $db, $dbDomain, $name, $id ) {
$this->db = $db;
- $this->wikiId = $wikiId;
+ $this->dbDomain = $dbDomain;
$this->name = $name;
$this->id = intval( $id );
$this->newOptions = [];
/**
* Confirm the selected database name is a valid local interwiki database name.
*
- * @param string $wikiId Database name
+ * @param string $dbDomain Database name
* @return bool
*/
- public static function validDatabase( $wikiId ) {
+ public static function validDatabase( $dbDomain ) {
global $wgLocalDatabases;
- return in_array( $wikiId, $wgLocalDatabases );
+ return in_array( $dbDomain, $wgLocalDatabases );
}
/**
* Same as User::whoIs()
*
- * @param string $wikiId Database name
+ * @param string $dbDomain Database name
* @param int $id User ID
- * @param bool $ignoreInvalidDB If true, don't check if $wikiId is in $wgLocalDatabases
+ * @param bool $ignoreInvalidDB If true, don't check if $dbDomain is in $wgLocalDatabases
* @return string User name or false if the user doesn't exist
*/
- public static function whoIs( $wikiId, $id, $ignoreInvalidDB = false ) {
- $user = self::newFromId( $wikiId, $id, $ignoreInvalidDB );
+ public static function whoIs( $dbDomain, $id, $ignoreInvalidDB = false ) {
+ $user = self::newFromId( $dbDomain, $id, $ignoreInvalidDB );
if ( $user ) {
return $user->name;
} else {
/**
* Factory function; get a remote user entry by ID number.
*
- * @param string $wikiId Database name
+ * @param string $dbDomain Database name
* @param int $id User ID
- * @param bool $ignoreInvalidDB If true, don't check if $wikiId is in $wgLocalDatabases
+ * @param bool $ignoreInvalidDB If true, don't check if $dbDomain is in $wgLocalDatabases
* @return UserRightsProxy|null If doesn't exist
*/
- public static function newFromId( $wikiId, $id, $ignoreInvalidDB = false ) {
- return self::newFromLookup( $wikiId, 'user_id', intval( $id ), $ignoreInvalidDB );
+ public static function newFromId( $dbDomain, $id, $ignoreInvalidDB = false ) {
+ return self::newFromLookup( $dbDomain, 'user_id', intval( $id ), $ignoreInvalidDB );
}
/**
* Factory function; get a remote user entry by name.
*
- * @param string $wikiId Database name
+ * @param string $dbDomain Database name
* @param string $name User name
- * @param bool $ignoreInvalidDB If true, don't check if $wikiId is in $wgLocalDatabases
+ * @param bool $ignoreInvalidDB If true, don't check if $dbDomain is in $wgLocalDatabases
* @return UserRightsProxy|null If doesn't exist
*/
- public static function newFromName( $wikiId, $name, $ignoreInvalidDB = false ) {
- return self::newFromLookup( $wikiId, 'user_name', $name, $ignoreInvalidDB );
+ public static function newFromName( $dbDomain, $name, $ignoreInvalidDB = false ) {
+ return self::newFromLookup( $dbDomain, 'user_name', $name, $ignoreInvalidDB );
}
/**
- * @param string $wikiId
+ * @param string $dbDomain
* @param string $field
* @param string $value
* @param bool $ignoreInvalidDB
* @return null|UserRightsProxy
*/
- private static function newFromLookup( $wikiId, $field, $value, $ignoreInvalidDB = false ) {
+ private static function newFromLookup( $dbDomain, $field, $value, $ignoreInvalidDB = false ) {
global $wgSharedDB, $wgSharedTables;
// If the user table is shared, perform the user query on it,
// but don't pass it to the UserRightsProxy,
if ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
$userdb = self::getDB( $wgSharedDB, $ignoreInvalidDB );
} else {
- $userdb = self::getDB( $wikiId, $ignoreInvalidDB );
+ $userdb = self::getDB( $dbDomain, $ignoreInvalidDB );
}
- $db = self::getDB( $wikiId, $ignoreInvalidDB );
+ $db = self::getDB( $dbDomain, $ignoreInvalidDB );
if ( $db && $userdb ) {
$row = $userdb->selectRow( 'user',
if ( $row !== false ) {
return new UserRightsProxy(
- $db, $wikiId, $row->user_name, intval( $row->user_id ) );
+ $db, $dbDomain, $row->user_name, intval( $row->user_id ) );
}
}
return null;
* Open a database connection to work on for the requested user.
* This may be a new connection to another database for remote users.
*
- * @param string $wikiId
- * @param bool $ignoreInvalidDB If true, don't check if $wikiId is in $wgLocalDatabases
+ * @param string $dbDomain
+ * @param bool $ignoreInvalidDB If true, don't check if $dbDomain is in $wgLocalDatabases
* @return IDatabase|null If invalid selection
*/
- public static function getDB( $wikiId, $ignoreInvalidDB = false ) {
- if ( $ignoreInvalidDB || self::validDatabase( $wikiId ) ) {
- if ( WikiMap::isCurrentWikiId( $wikiId ) ) {
+ public static function getDB( $dbDomain, $ignoreInvalidDB = false ) {
+ if ( $ignoreInvalidDB || self::validDatabase( $dbDomain ) ) {
+ if ( WikiMap::isCurrentWikiId( $dbDomain ) ) {
// Hmm... this shouldn't happen though. :)
return wfGetDB( DB_MASTER );
} else {
- return wfGetDB( DB_MASTER, [], $wikiId );
+ return wfGetDB( DB_MASTER, [], $dbDomain );
}
}
return null;
* @return string
*/
public function getName() {
- return $this->name . '@' . $this->wikiId;
+ return $this->name . '@' . $this->dbDomain;
}
/**