From: Sam Reed Date: Tue, 4 Jan 2011 23:59:39 +0000 (+0000) Subject: * (bug 26460) Add support for listing category members by category pageid X-Git-Tag: 1.31.0-rc.0~32816 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=5885c02a1a8bfbcc042850226209fd6a644f3b99;p=lhc%2Fweb%2Fwiklou.git * (bug 26460) Add support for listing category members by category pageid --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 4fa6b172bc..0260cc47d8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -71,6 +71,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 26559) list=allusers auprop=rights does not match list=users usprop=rights * (bug 26560) On allusers if limit < total number of users, last user gets duplicate * (bug 25135) add "normalized" to action=parse +* (bug 26460) Add support for listing category members by category pageid === Languages updated in 1.18 === diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 4b3b3dbcfd..2ba305766d 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -55,10 +55,22 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { private function run( $resultPageSet = null ) { $params = $this->extractRequestParams(); - $categoryTitle = Title::newFromText( $params['title'] ); + $this->requireOnlyOneParameter( $params, 'title', 'pageid' ); - if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY ) { - $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' ); + if ( isset( $params['title'] ) ) { + $categoryTitle = Title::newFromText( $params['title'] ); + + if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY ) { + $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' ); + } + } elseif( isset( $params['pageid'] ) ) { + $categoryTitle = Title::newFromID( $params['pageid'] ); + + if ( !$categoryTitle ) { + $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) ); + } elseif ( $categoryTitle->getNamespace() != NS_CATEGORY ) { + $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' ); + } } $prop = array_flip( $params['prop'] ); @@ -208,7 +220,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { return array( 'title' => array( ApiBase::PARAM_TYPE => 'string', - ApiBase::PARAM_REQUIRED => true + ), + 'pageid' => array( + ApiBase::PARAM_TYPE => 'integer' ), 'prop' => array( ApiBase::PARAM_DFLT => 'ids|title', @@ -261,7 +275,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { global $wgMiserMode; $p = $this->getModulePrefix(); $desc = array( - 'title' => 'Which category to enumerate (required). Must include Category: prefix', + 'title' => 'Which category to enumerate (required). Must include Category: prefix. Cannot be used together with cmpageid', + 'pageid' => 'Page ID of the category to enumerate. Cannot be used together with cmtitle', 'prop' => array( 'What pieces of information to include', ' ids - Adds the page ID', @@ -298,6 +313,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { array( 'code' => 'notitle', 'info' => 'The cmtitle parameter is required' ), array( 'code' => 'invalidcategory', 'info' => 'The category name you entered is not valid' ), array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ), + array( 'nosuchpageid', 'pageid' ), ) ); }