jenkins-bot has submitted this change and it was merged. Change subject: ApiQuerySiteinfo: Add prop=restrictions for protection information ......................................................................
ApiQuerySiteinfo: Add prop=restrictions for protection information As pointed out on VPT, we previously had no way to find out about these. This just dumps the raw config variables for now. They are documented in DefaultSettings as having some magic applied to them when used, maybe we should apply this magic here too, or in Setup.php? https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&oldid=594218538#API_query_to_list_available_protection_levels_for_a_wiki.3F Change-Id: I4c1303f2a6fe6b60b44e960cc1253c555fc658dc --- M RELEASE-NOTES-1.23 M includes/api/ApiQuerySiteinfo.php 2 files changed, 26 insertions(+), 0 deletions(-) Approvals: Anomie: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 59118bd..42fd16b 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -158,6 +158,8 @@ * (bug 32151) ApiWatch now has pageset capabilities (titles/pageids/generators). Title parameter is now deprecated. * (bug 23005) Added action=revisiondelete. +* Added siprop=restrictions to API action=query&meta=siteinfo for querying + possible page restriction (protection) levels and types. === Languages updated in 1.23 === diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 9cf3afd..a078013 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -78,6 +78,9 @@ case 'rightsinfo': $fit = $this->appendRightsInfo( $p ); break; + case 'restrictions': + $fit = $this->appendRestrictions( $p ); + break; case 'languages': $fit = $this->appendLanguages( $p ); break; @@ -615,6 +618,25 @@ return $this->getResult()->addValue( 'query', $property, $data ); } + protected function appendRestrictions( $property ) { + global $wgRestrictionTypes, $wgRestrictionLevels, + $wgCascadingRestrictionLevels, $wgSemiprotectedRestrictionLevels; + + $data = array( + 'types' => $wgRestrictionTypes, + 'levels' => $wgRestrictionLevels, + 'cascadinglevels' => $wgCascadingRestrictionLevels, + 'semiprotectedlevels' => $wgSemiprotectedRestrictionLevels, + ); + + $this->getResult()->setIndexedTagName( $data['types'], 'type' ); + $this->getResult()->setIndexedTagName( $data['levels'], 'level' ); + $this->getResult()->setIndexedTagName( $data['cascadinglevels'], 'level' ); + $this->getResult()->setIndexedTagName( $data['semiprotectedlevels'], 'level' ); + + return $this->getResult()->addValue( 'query', $property, $data ); + } + public function appendLanguages( $property ) { $params = $this->extractRequestParams(); $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : ''; @@ -737,6 +759,7 @@ 'extensions', 'fileextensions', 'rightsinfo', + 'restrictions', 'languages', 'skins', 'extensiontags', @@ -778,6 +801,7 @@ ' extensions - Returns extensions installed on the wiki', ' fileextensions - Returns list of file extensions allowed to be uploaded', ' rightsinfo - Returns wiki rights (license) information if available', + ' restrictions - Returns information on available restriction (protection) types', ' languages - Returns a list of languages MediaWiki supports' . "(optionally localised by using {$p}inlanguagecode)", ' skins - Returns a list of all enabled skins', -- To view, visit https://gerrit.wikimedia.org/r/111799 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4c1303f2a6fe6b60b44e960cc1253c555fc658dc Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Bartosz DziewoĆski <[email protected]> Gerrit-Reviewer: Anomie <[email protected]> Gerrit-Reviewer: Yurik <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
