r79636 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79635‎ | r79636 | r79637 >
Date:23:59, 4 January 2011
Author:reedy
Status:ok
Tags:
Comment:
* (bug 26460) Add support for listing category members by category pageid
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -55,10 +55,22 @@
5656 private function run( $resultPageSet = null ) {
5757 $params = $this->extractRequestParams();
5858
59 - $categoryTitle = Title::newFromText( $params['title'] );
 59+ $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
6060
61 - if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY ) {
62 - $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' );
 61+ if ( isset( $params['title'] ) ) {
 62+ $categoryTitle = Title::newFromText( $params['title'] );
 63+
 64+ if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY ) {
 65+ $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' );
 66+ }
 67+ } elseif( isset( $params['pageid'] ) ) {
 68+ $categoryTitle = Title::newFromID( $params['pageid'] );
 69+
 70+ if ( !$categoryTitle ) {
 71+ $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) );
 72+ } elseif ( $categoryTitle->getNamespace() != NS_CATEGORY ) {
 73+ $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' );
 74+ }
6375 }
6476
6577 $prop = array_flip( $params['prop'] );
@@ -208,8 +220,10 @@
209221 return array(
210222 'title' => array(
211223 ApiBase::PARAM_TYPE => 'string',
212 - ApiBase::PARAM_REQUIRED => true
213224 ),
 225+ 'pageid' => array(
 226+ ApiBase::PARAM_TYPE => 'integer'
 227+ ),
214228 'prop' => array(
215229 ApiBase::PARAM_DFLT => 'ids|title',
216230 ApiBase::PARAM_ISMULTI => true,
@@ -261,7 +275,8 @@
262276 global $wgMiserMode;
263277 $p = $this->getModulePrefix();
264278 $desc = array(
265 - 'title' => 'Which category to enumerate (required). Must include Category: prefix',
 279+ 'title' => 'Which category to enumerate (required). Must include Category: prefix. Cannot be used together with cmpageid',
 280+ 'pageid' => 'Page ID of the category to enumerate. Cannot be used together with cmtitle',
266281 'prop' => array(
267282 'What pieces of information to include',
268283 ' ids - Adds the page ID',
@@ -298,6 +313,7 @@
299314 array( 'code' => 'notitle', 'info' => 'The cmtitle parameter is required' ),
300315 array( 'code' => 'invalidcategory', 'info' => 'The category name you entered is not valid' ),
301316 array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
 317+ array( 'nosuchpageid', 'pageid' ),
302318 ) );
303319 }
304320
Index: trunk/phase3/RELEASE-NOTES
@@ -71,6 +71,7 @@
7272 * (bug 26559) list=allusers auprop=rights does not match list=users usprop=rights
7373 * (bug 26560) On allusers if limit < total number of users, last user gets duplicate
7474 * (bug 25135) add "normalized" to action=parse
 75+* (bug 26460) Add support for listing category members by category pageid
7576
7677 === Languages updated in 1.18 ===
7778

Status & tagging log