* (bug 26460) Add support for listing category members by category pageid
authorSam Reed <reedy@users.mediawiki.org>
Tue, 4 Jan 2011 23:59:39 +0000 (23:59 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 4 Jan 2011 23:59:39 +0000 (23:59 +0000)
RELEASE-NOTES
includes/api/ApiQueryCategoryMembers.php

index 4fa6b17..0260cc4 100644 (file)
@@ -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 ===
 
index 4b3b3db..2ba3057 100644 (file)
@@ -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' ),
                ) );
        }