r80540 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80539‎ | r80540 | r80541 >
Date:00:13, 19 January 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Various fixes for API category changes:
* Followup r80326: clarify description of type property
* Fix r80355: need to use addWhereRange() for the static ORDER BY on cl_type as well, to make sure it flips direction when needed (mixed-direction multi-field ORDER BYs are not indexed)
* Followup r80358: use current not previous value for cl_from, and use >= instead of > . This is the way continues are normally done
* Followup r80362: clarify description for sortkeyprefix property
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php
@@ -119,13 +119,12 @@
120120
121121 $this->addOption( 'USE INDEX', 'cl_timestamp' );
122122 } else {
123 - $this->addOption( 'ORDER BY', 'cl_type' );
124 -
 123+ // The below produces ORDER BY cl_type, cl_sortkey, cl_from, possibly with DESC added to each of them
 124+ $this->addWhereRange( 'cl_type', $dir, null, null );
125125 $this->addWhereRange( 'cl_sortkey',
126126 $dir,
127127 $params['startsortkey'],
128128 $params['endsortkey'] );
129 -
130129 $this->addWhereRange( 'cl_from', $dir, null, null );
131130 $this->addOption( 'USE INDEX', 'cl_sortkey' );
132131 }
@@ -138,7 +137,6 @@
139138 $this->addOption( 'LIMIT', $limit + 1 );
140139
141140 $count = 0;
142 - $lastFrom = null;
143141 $res = $this->select( __METHOD__ );
144142 foreach ( $res as $row ) {
145143 if ( ++ $count > $limit ) {
@@ -147,7 +145,7 @@
148146 if ( $params['sort'] == 'timestamp' ) {
149147 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
150148 } else {
151 - $this->setContinueEnumParameter( 'continue', $lastFrom );
 149+ $this->setContinueEnumParameter( 'continue', $row->cl_from );
152150 }
153151 break;
154152 }
@@ -187,14 +185,13 @@
188186 if ( $params['sort'] == 'timestamp' ) {
189187 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
190188 } else {
191 - $this->setContinueEnumParameter( 'continue', $lastFrom );
 189+ $this->setContinueEnumParameter( 'continue', $row->cl_from );
192190 }
193191 break;
194192 }
195193 } else {
196194 $resultPageSet->processDbRow( $row );
197195 }
198 - $lastFrom = $row->cl_from; // detect duplicate sortkeys
199196 }
200197
201198 if ( is_null( $resultPageSet ) ) {
@@ -213,7 +210,7 @@
214211
215212 $encFrom = $this->getDB()->addQuotes( intval( $continue ) );
216213
217 - $op = ( $dir == 'desc' ? '<' : '>' );
 214+ $op = ( $dir == 'desc' ? '<=' : '>=' );
218215
219216 $this->addWhere( "cl_from $op $encFrom" );
220217 }
@@ -294,9 +291,9 @@
295292 'What pieces of information to include',
296293 ' ids - Adds the page ID',
297294 ' title - Adds the title and namespace ID of the page',
298 - ' sortkey - Adds the sortkey used for the category (note, may be non human readable)',
299 - ' sortkeyprefix - Adds the sortkey prefix used for the category',
300 - ' type - Adds the type that the page has been categorised as',
 295+ ' sortkey - Adds the sortkey used for sorting in the category (may not be human-readble)',
 296+ ' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)',
 297+ ' type - Adds the type that the page has been categorised as (page, subcat or file)',
301298 ' timestamp - Adds the timestamp of when the page was included',
302299 ),
303300 'namespace' => 'Only include pages in these namespaces',

Follow-up revisions

RevisionCommit summaryAuthorDate
r807221.17: MFT r80324, r80326, r80328, r80339, r80350, r80351, r80355, r80358, r80...catrope23:00, 21 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80324Start of bug 24650 Fix API to work with categorylinks changes...reedy21:08, 14 January 2011
r80326Followup r80324, add type property descriptionreedy21:15, 14 January 2011
r80355Bye bye filesorts. Making order by cl_type, and then addWhereRange adds cl_so...reedy23:45, 14 January 2011
r80358More for bug 24650. Update continue to be usable unique thingreedy00:00, 15 January 2011
r80362Last bits of bug 24650 Fix API to work with categorylinks changes...reedy00:10, 15 January 2011

Comments

#Comment by Reedy (talk | contribs)   12:13, 19 January 2011

Bleh. Nothing too major by the looks of it then :), I'll review this properly when I'm back home in the next couple of days, rather than just catching up on the Internets using my phone tethered in LHR :)

Status & tagging log