From 464e997a1fe96e65bc47c2be2838c8ffb5e0e2b1 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 10 Sep 2007 14:17:33 +0000 Subject: [PATCH] *(bug 11275) Enable descending sort in API categorymembers --- RELEASE-NOTES | 2 ++ includes/api/ApiQueryCategoryMembers.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a37cc5fd06..cfe1cb76ba 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -48,6 +48,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN Full API documentation is available at http://www.mediawiki.org/wiki/API +* (bug 11275) Enable descending sort in categorymembers + === Languages updated in 1.12 === * Arabic (ar) diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 79dc9b4349..487fea8b16 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -78,12 +78,12 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { if($params['sort'] == 'timestamp') { $this->addOption('USE INDEX', 'cl_timestamp'); - $this->addOption('ORDER BY', 'cl_to, cl_timestamp'); + $this->addOption('ORDER BY', 'cl_to, cl_timestamp' . ($params['dir'] == 'desc' ? ' DESC' : '')); } else { $this->addOption('USE INDEX', 'cl_sortkey'); - $this->addOption('ORDER BY', 'cl_to, cl_sortkey, cl_from'); + $this->addOption('ORDER BY', 'cl_to, cl_sortkey' . ($params['dir'] == 'desc' ? ' DESC' : '') . ', cl_from'); } $this->addWhere('cl_from=page_id'); @@ -203,6 +203,13 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { 'sortkey', 'timestamp' ) + ), + 'dir' => array( + ApiBase :: PARAM_DFLT => 'asc', + ApiBase :: PARAM_TYPE => array( + 'asc', + 'desc' + ) ) ); } @@ -213,6 +220,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { 'prop' => 'What pieces of information to include', 'namespace' => 'Only include pages in these namespaces', 'sort' => 'Property to sort by', + 'dir' => 'In which direction to sort', 'continue' => 'For large categories, give the value retured from previous query', 'limit' => 'The maximum number of pages to return.', ); -- 2.20.1