From 1be7d14726bedd7f10d53bc45e8ff615903ed81d Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 17 Oct 2008 14:26:56 +0000 Subject: [PATCH] * API: (bug 15995) Added cmstartsortkey and cmendsortkey parameters to list=categorymembers, mirroring cmstart and cmend for timestamps * Drop useless and possibly filesorting ORDER BY cl_to from list=categorymembers * Handle ORDER BY cl_sortkey, cl_from (possibly with DESC appended to each of them) with addWhereRange() calls --- RELEASE-NOTES | 2 ++ includes/api/ApiQueryCategoryMembers.php | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c294dccaad..2f8d0f02e3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -339,6 +339,8 @@ The following extensions are migrated into MediaWiki 1.14: and patrolmarks right * (bug 15985) acfrom and aifrom parameters didn't work when sorting in descending order. +* (bug 15995) Add cmstartsortkey and cmendsortkey parameters to + list=categorymembers === Languages updated in 1.14 === diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 91f822acf5..ad5836caa4 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -76,17 +76,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $this->addTables(array('page','categorylinks')); // must be in this order for 'USE INDEX' // Not needed after bug 10280 is applied to servers if($params['sort'] == 'timestamp') - { $this->addOption('USE INDEX', 'cl_timestamp'); - // cl_timestamp will be added by addWhereRange() later - $this->addOption('ORDER BY', 'cl_to'); - } else - { - $dir = ($params['dir'] == 'desc' ? ' DESC' : ''); $this->addOption('USE INDEX', 'cl_sortkey'); - $this->addOption('ORDER BY', 'cl_to, cl_sortkey' . $dir . ', cl_from' . $dir); - } $this->addWhere('cl_from=page_id'); $this->setContinuation($params['continue'], $params['dir']); @@ -94,6 +86,11 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $this->addWhereFld('page_namespace', $params['namespace']); if($params['sort'] == 'timestamp') $this->addWhereRange('cl_timestamp', ($params['dir'] == 'asc' ? 'newer' : 'older'), $params['start'], $params['end']); + else + { + $this->addWhereRange('cl_sortkey', ($params['dir'] == 'asc' ? 'newer' : 'older'), $params['startsortkey'], $params['endsortkey']); + $this->addWhereRange('cl_from', ($params['dir'] == 'asc' ? 'newer' : 'older'), null, null); + } $limit = $params['limit']; $this->addOption('LIMIT', $limit +1); @@ -225,7 +222,9 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { ), 'end' => array( ApiBase :: PARAM_TYPE => 'timestamp' - ) + ), + 'startsortkey' => null, + 'endsortkey' => null, ); } @@ -238,6 +237,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { 'dir' => 'In which direction to sort', 'start' => 'Timestamp to start listing from. Can only be used with cmsort=timestamp', 'end' => 'Timestamp to end listing at. Can only be used with cmsort=timestamp', + 'startsortkey' => 'Sortkey to start listing from. Can only be used with cmsort=sortkey', + 'endsortkey' => 'Sortkey to end listing at. Can only be used with cmsort=sortkey', 'continue' => 'For large categories, give the value retured from previous query', 'limit' => 'The maximum number of pages to return.', ); -- 2.20.1