r101306 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101305‎ | r101306 | r101307 >
Date:18:49, 30 October 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Introduce cmstartsortkeyprefix and cmendsortkeyprefix parameters so categorized pages can be looked up using a category+sortkey combination. Based on a feature request from Danny B on IRC
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -147,11 +147,18 @@
148148 $this->addWhereRange( 'cl_sortkey', $dir, null, null );
149149 $this->addWhereRange( 'cl_from', $dir, null, null );
150150 } else {
 151+ $startsortkey = $params['startsortkeyprefix'] !== null ?
 152+ Collation::singleton()->getSortkey( $params['startsortkeyprefix'] ) :
 153+ $params['startsortkey'];
 154+ $endsortkey = $params['endsortkeyprefix'] !== null ?
 155+ Collation::singleton()->getSortkey( $params['endsortkeyprefix'] ) :
 156+ $params['endsortkey'];
 157+
151158 // The below produces ORDER BY cl_sortkey, cl_from, possibly with DESC added to each of them
152159 $this->addWhereRange( 'cl_sortkey',
153160 $dir,
154 - $params['startsortkey'],
155 - $params['endsortkey'] );
 161+ $startsortkey,
 162+ $endsortkey );
156163 $this->addWhereRange( 'cl_from', $dir, null, null );
157164 }
158165 $this->addOption( 'USE INDEX', 'cl_sortkey' );
@@ -325,6 +332,8 @@
326333 ),
327334 'startsortkey' => null,
328335 'endsortkey' => null,
 336+ 'startsortkeyprefix' => null,
 337+ 'endsortkeyprefix' => null,
329338 );
330339 }
331340
@@ -351,6 +360,8 @@
352361 'end' => "Timestamp to end listing at. Can only be used with {$p}sort=timestamp",
353362 'startsortkey' => "Sortkey to start listing from. Must be given in binary format. Can only be used with {$p}sort=sortkey",
354363 'endsortkey' => "Sortkey to end listing at. Must be given in binary format. Can only be used with {$p}sort=sortkey",
 364+ 'startsortkeyprefix' => "Sortkey prefix to start listing from. Can only be used with {$p}sort=sortkey. Overrides {$p}startsortkey",
 365+ '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",
355366 'continue' => 'For large categories, give the value retured from previous query',
356367 'limit' => 'The maximum number of pages to return.',
357368 );

Sign-offs

UserFlagDate
Reedyinspected02:52, 1 November 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r101448MFT r101306reedy03:11, 1 November 2011

Comments

#Comment by Duplicatebug (talk | contribs)   20:52, 1 November 2011

That "BEFORE" is bad. It is impossible to have this act like the other places, where start/end or from/to is used? Having a uniform way over the whole api makes the work with it easy.

What is the behaviour, when using the cmdir=desc? Than is end inside and start not.

Status & tagging log