[MediaWiki-commits] [Gerrit] mediawiki...CentralAuth[master]: Add "id" param to ApiQueryGlobalUserInfo
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/386078 ) Change subject: Add "id" param to ApiQueryGlobalUserInfo .. Add "id" param to ApiQueryGlobalUserInfo There's no other way to retrieve user information by global ID. Change-Id: I927fb7c480bc90230d4fabd2b45816df40aee1b2 --- M i18n/en.json M i18n/qqq.json M includes/api/ApiQueryGlobalUserInfo.php 3 files changed, 19 insertions(+), 8 deletions(-) Approvals: jenkins-bot: Verified Anomie: Looks good to me, approved diff --git a/i18n/en.json b/i18n/en.json index a4717e6..5e5777a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -537,7 +537,8 @@ "apihelp-query+globalgroups-example-2": "Show global groups with the rights they grant", "apihelp-query+globaluserinfo-description": "Show information about a global user.", "apihelp-query+globaluserinfo-summary": "Show information about a global user.", - "apihelp-query+globaluserinfo-param-user": "User to get information about. Defaults to the current user.", + "apihelp-query+globaluserinfo-param-user": "User to get information about. If $1user and $1id both are omitted, it defaults to the current user.", + "apihelp-query+globaluserinfo-param-id": "Global user ID to get information about. If $1user and $1id both are omitted, it defaults to the current user.", "apihelp-query+globaluserinfo-param-prop": "Which properties to get:\n;groups:Get a list of global groups this user belongs to.\n;rights:Get a list of global rights this user has.\n;merged:Get a list of merged accounts.\n;unattached:Get a list of unattached accounts.\n;editcount:Get the user's global edit count.", "apihelp-query+globaluserinfo-example-1": "Get information about the current global user", "apihelp-query+globaluserinfo-example-2": "Get information about global user [[User:Example|Example]]", diff --git a/i18n/qqq.json b/i18n/qqq.json index f0ba049..fe01ce0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -554,6 +554,7 @@ "apihelp-query+globaluserinfo-description": "{{doc-apihelp-description|query+globaluserinfo}}", "apihelp-query+globaluserinfo-summary": "{{doc-apihelp-summary|query+globaluserinfo}}", "apihelp-query+globaluserinfo-param-user": "{{doc-apihelp-param|query+globaluserinfo|user}}", + "apihelp-query+globaluserinfo-param-id": "{{doc-apihelp-param|query+globaluserinfo|id}}", "apihelp-query+globaluserinfo-param-prop": "{{doc-apihelp-param|query+globaluserinfo|prop}}", "apihelp-query+globaluserinfo-example-1": "{{doc-apihelp-example|query+globaluserinfo}}", "apihelp-query+globaluserinfo-example-2": "{{doc-apihelp-example|query+globaluserinfo}}", diff --git a/includes/api/ApiQueryGlobalUserInfo.php b/includes/api/ApiQueryGlobalUserInfo.php index cafe92f..aa3a7c5 100644 --- a/includes/api/ApiQueryGlobalUserInfo.php +++ b/includes/api/ApiQueryGlobalUserInfo.php @@ -36,16 +36,22 @@ public function execute() { $params = $this->extractRequestParams(); $prop = array_flip( (array)$params['prop'] ); - if ( is_null( $params['user'] ) ) { + if ( is_null( $params['user'] ) && is_null( $params['id'] ) ) { $params['user'] = $this->getUser()->getName(); } - $username = User::getCanonicalName( $params['user'] ); - if ( $username === false ) { - $this->dieWithError( [ 'apierror-invaliduser', wfEscapeWikiText( $params['user'] ) ] ); + if ( is_null( $params['user'] ) ) { + $user = CentralAuthUser::newFromId( $params['id'] ); + if ( $user === false ) { + $this->dieWithError( [ 'apierror-invaliduserid', wfEscapeWikiText( $params['id'] ) ] ); + } + } else { + $username = User::getCanonicalName( $params['user'] ); + if ( $username === false ) { + $this->dieWithError( [ 'apierror-invaliduser', wfEscapeWikiText( $params['user'] ) ] ); + } + $user = CentralAuthUser::getInstanceByName( $username ); } - - $user = CentralAuthUser::getInstanceByName( $username ); // Add basic info $result = $this->getResult(); @@ -144,7 +150,7 @@ } public function getCacheMode( $params ) { - if ( !is_null( $params['user'] ) ) { + if ( !is_null( $params['user'] ) || !is_null( $params['id'] ) ) { // URL determines user, public caching is fine return 'public'; } else { @@ -158,6 +164,9 @@ 'user' => [ ApiB
[MediaWiki-commits] [Gerrit] mediawiki...CentralAuth[master]: Add "id" param to ApiQueryGlobalUserInfo
Ladsgroup has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/386078 ) Change subject: Add "id" param to ApiQueryGlobalUserInfo .. Add "id" param to ApiQueryGlobalUserInfo It's useful and we can't get it any other way Change-Id: I927fb7c480bc90230d4fabd2b45816df40aee1b2 --- M i18n/en.json M i18n/qqq.json M includes/api/ApiQueryGlobalUserInfo.php 3 files changed, 16 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/78/386078/1 diff --git a/i18n/en.json b/i18n/en.json index a4717e6..7e1dd77 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -537,7 +537,8 @@ "apihelp-query+globalgroups-example-2": "Show global groups with the rights they grant", "apihelp-query+globaluserinfo-description": "Show information about a global user.", "apihelp-query+globaluserinfo-summary": "Show information about a global user.", - "apihelp-query+globaluserinfo-param-user": "User to get information about. Defaults to the current user.", + "apihelp-query+globaluserinfo-param-user": "User to get information about. If user and id both are null, it defaults to the current user.", + "apihelp-query+globaluserinfo-param-id": "Global user id to get information about. If user and id both are null, it defaults to the current user.", "apihelp-query+globaluserinfo-param-prop": "Which properties to get:\n;groups:Get a list of global groups this user belongs to.\n;rights:Get a list of global rights this user has.\n;merged:Get a list of merged accounts.\n;unattached:Get a list of unattached accounts.\n;editcount:Get the user's global edit count.", "apihelp-query+globaluserinfo-example-1": "Get information about the current global user", "apihelp-query+globaluserinfo-example-2": "Get information about global user [[User:Example|Example]]", diff --git a/i18n/qqq.json b/i18n/qqq.json index f0ba049..fe01ce0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -554,6 +554,7 @@ "apihelp-query+globaluserinfo-description": "{{doc-apihelp-description|query+globaluserinfo}}", "apihelp-query+globaluserinfo-summary": "{{doc-apihelp-summary|query+globaluserinfo}}", "apihelp-query+globaluserinfo-param-user": "{{doc-apihelp-param|query+globaluserinfo|user}}", + "apihelp-query+globaluserinfo-param-id": "{{doc-apihelp-param|query+globaluserinfo|id}}", "apihelp-query+globaluserinfo-param-prop": "{{doc-apihelp-param|query+globaluserinfo|prop}}", "apihelp-query+globaluserinfo-example-1": "{{doc-apihelp-example|query+globaluserinfo}}", "apihelp-query+globaluserinfo-example-2": "{{doc-apihelp-example|query+globaluserinfo}}", diff --git a/includes/api/ApiQueryGlobalUserInfo.php b/includes/api/ApiQueryGlobalUserInfo.php index cafe92f..c317491 100644 --- a/includes/api/ApiQueryGlobalUserInfo.php +++ b/includes/api/ApiQueryGlobalUserInfo.php @@ -36,16 +36,19 @@ public function execute() { $params = $this->extractRequestParams(); $prop = array_flip( (array)$params['prop'] ); - if ( is_null( $params['user'] ) ) { + if ( is_null( $params['user'] ) && is_null( $params['id'] ) ) { $params['user'] = $this->getUser()->getName(); } - $username = User::getCanonicalName( $params['user'] ); - if ( $username === false ) { - $this->dieWithError( [ 'apierror-invaliduser', wfEscapeWikiText( $params['user'] ) ] ); + if ( is_null( $params['user'] ) ) { + $user = CentralAuthUser::newFromId( $params['id'] ); + } else { + $username = User::getCanonicalName( $params['user'] ); + if ( $username === false ) { + $this->dieWithError( [ 'apierror-invaliduser', wfEscapeWikiText( $params['user'] ) ] ); + } + $user = CentralAuthUser::getInstanceByName( $username ); } - - $user = CentralAuthUser::getInstanceByName( $username ); // Add basic info $result = $this->getResult(); @@ -144,7 +147,7 @@ } public function getCacheMode( $params ) { - if ( !is_null( $params['user'] ) ) { + if ( !is_null( $params['user'] ) || !is_null( $params['id'] ) ) { // URL determines user, public caching is fine return 'public'; } else { @@ -158,6 +161,9 @@ 'user' => [ ApiBase::PARAM_TYPE => 'user', ], + 'id' => [ + self::PARAM_TYPE => 'integer', + ], 'prop'