X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fuser%2FUserRightsProxy.php;h=603d3339a81fed6b63c985a02f8d9d3bcead655c;hb=cfd56e52d96e7c65215a4d9d2f10962794c67f88;hp=0b7a7200f91d739916807554c9790c1a207d3006;hpb=1ced36fb11be478225e061f07129aac43461924c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/user/UserRightsProxy.php b/includes/user/UserRightsProxy.php index 0b7a7200f9..603d3339a8 100644 --- a/includes/user/UserRightsProxy.php +++ b/includes/user/UserRightsProxy.php @@ -30,7 +30,7 @@ class UserRightsProxy { /** @var IDatabase */ private $db; /** @var string */ - private $wikiId; + private $dbDomain; /** @var string */ private $name; /** @var int */ @@ -42,13 +42,13 @@ class UserRightsProxy { * @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 = []; @@ -57,24 +57,24 @@ class UserRightsProxy { /** * 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 { @@ -85,35 +85,35 @@ class UserRightsProxy { /** * 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, @@ -121,10 +121,10 @@ class 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', @@ -134,7 +134,7 @@ class UserRightsProxy { 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; @@ -144,17 +144,17 @@ class UserRightsProxy { * 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; @@ -180,7 +180,7 @@ class UserRightsProxy { * @return string */ public function getName() { - return $this->name . '@' . $this->wikiId; + return $this->name . '@' . $this->dbDomain; } /**