From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/api/ApiQueryCategoryMembers.php | 69 +++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 24 deletions(-) (limited to 'includes/api/ApiQueryCategoryMembers.php') diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 4b19b7e8..55ce0234 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -4,7 +4,7 @@ * * Created on June 14, 2007 * - * Copyright © 2006 Yuri Astrakhan @gmail.com + * Copyright © 2006 Yuri Astrakhan "@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,22 +54,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { private function run( $resultPageSet = null ) { $params = $this->extractRequestParams(); - $this->requireOnlyOneParameter( $params, 'title', 'pageid' ); - - 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' ); - } + $categoryTitle = $this->getTitleOrPageId( $params )->getTitle(); + if ( $categoryTitle->getNamespace() != NS_CATEGORY ) { + $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' ); } $prop = array_flip( $params['prop'] ); @@ -107,10 +94,10 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $this->addWhereFld( 'page_namespace', $params['namespace'] ); } - $dir = $params['dir'] == 'asc' ? 'newer' : 'older'; + $dir = in_array( $params['dir'], array( 'asc', 'ascending', 'newer' ) ) ? 'newer' : 'older'; if ( $params['sort'] == 'timestamp' ) { - $this->addWhereRange( 'cl_timestamp', + $this->addTimestampWhereRange( 'cl_timestamp', $dir, $params['start'], $params['end'] ); @@ -313,10 +300,15 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { ) ), 'dir' => array( - ApiBase::PARAM_DFLT => 'asc', + ApiBase::PARAM_DFLT => 'ascending', ApiBase::PARAM_TYPE => array( 'asc', - 'desc' + 'desc', + // Normalising with other modules + 'ascending', + 'descending', + 'newer', + 'older', ) ), 'start' => array( @@ -357,7 +349,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { 'endsortkey' => "Sortkey to end listing at. Must be given in binary format. Can only be used with {$p}sort=sortkey", 'startsortkeyprefix' => "Sortkey prefix to start listing from. Can only be used with {$p}sort=sortkey. Overrides {$p}startsortkey", 'endsortkeyprefix' => "Sortkey prefix to end listing BEFORE (not at, if this value occurs it will not be included!). Can only be used with {$p}sort=sortkey. Overrides {$p}endsortkey", - 'continue' => 'For large categories, give the value retured from previous query', + 'continue' => 'For large categories, give the value returned from previous query', 'limit' => 'The maximum number of pages to return.', ); @@ -372,17 +364,46 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { return $desc; } + public function getResultProperties() { + return array( + 'ids' => array( + 'pageid' => 'integer' + ), + 'title' => array( + 'ns' => 'namespace', + 'title' => 'string' + ), + 'sortkey' => array( + 'sortkey' => 'string' + ), + 'sortkeyprefix' => array( + 'sortkeyprefix' => 'string' + ), + 'type' => array( + 'type' => array( + ApiBase::PROP_TYPE => array( + 'page', + 'subcat', + 'file' + ) + ) + ), + 'timestamp' => array( + 'timestamp' => 'timestamp' + ) + ); + } + public function getDescription() { return 'List all pages in a given category'; } public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), - $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ), + $this->getTitleOrPageIdErrorMessage(), array( 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' ), ) ); } -- cgit v1.2.3-54-g00ecf