r92283 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92282‎ | r92283 | r92284 >
Date:19:15, 15 July 2011
Author:reedy
Status:ok
Tags:
Comment:
1.17wmf1: MFT r86257
Modified paths:
  • /branches/wmf/1.17wmf1/includes/api/ApiQueryCategories.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/api/ApiQueryCategoryMembers.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/api/ApiQueryCategoryMembers.php
@@ -107,7 +107,6 @@
108108 $this->addOption( 'USE INDEX', 'cl_timestamp' );
109109 } else {
110110 if ( $params['continue'] ) {
111 - // type|from|sortkey
112111 $cont = explode( '|', $params['continue'], 3 );
113112 if ( count( $cont ) != 3 ) {
114113 $this->dieUsage( 'Invalid continue param. You should pass the original value returned '.
@@ -120,8 +119,9 @@
121120 $queryTypes = array_slice( $queryTypes, $contTypeIndex );
122121
123122 // Add a WHERE clause for sortkey and from
124 - $from = intval( $cont[1] );
125 - $escSortkey = $this->getDB()->addQuotes( $cont[2] );
 123+ // pack( "H*", $foo ) is used to convert hex back to binary
 124+ $escSortkey = $this->getDB()->addQuotes( pack( "H*", $cont[1] ) );
 125+ $from = intval( $cont[2] );
126126 $op = $dir == 'newer' ? '>' : '<';
127127 // $contWhere is used further down
128128 $contWhere = "cl_sortkey $op $escSortkey OR " .
@@ -181,12 +181,9 @@
182182 if ( $params['sort'] == 'timestamp' ) {
183183 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
184184 } else {
185 - // Continue format is type|from|sortkey
186 - // The order is a bit weird but it's convenient to put the sortkey at the end
187 - // because we don't have to worry about pipes in the sortkey that way
188 - // (and type and from can't contain pipes anyway)
 185+ $sortkey = bin2hex( $row->cl_sortkey );
189186 $this->setContinueEnumParameter( 'continue',
190 - "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}"
 187+ "{$row->cl_type}|$sortkey|{$row->cl_from}"
191188 );
192189 }
193190 break;
@@ -210,7 +207,7 @@
211208 ApiQueryBase::addTitleInfo( $vals, $title );
212209 }
213210 if ( $fld_sortkey ) {
214 - $vals['sortkey'] = $row->cl_sortkey;
 211+ $vals['sortkey'] = bin2hex( $row->cl_sortkey );
215212 }
216213 if ( $fld_sortkeyprefix ) {
217214 $vals['sortkeyprefix'] = $row->cl_sortkey_prefix;
@@ -227,8 +224,9 @@
228225 if ( $params['sort'] == 'timestamp' ) {
229226 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
230227 } else {
 228+ $sortkey = bin2hex( $row->cl_sortkey );
231229 $this->setContinueEnumParameter( 'continue',
232 - "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}"
 230+ "{$row->cl_type}|$sortkey|{$row->cl_from}"
233231 );
234232 }
235233 break;
@@ -317,7 +315,7 @@
318316 'What pieces of information to include',
319317 ' ids - Adds the page ID',
320318 ' title - Adds the title and namespace ID of the page',
321 - ' sortkey - Adds the sortkey used for sorting in the category (may not be human-readble)',
 319+ ' sortkey - Adds the sortkey used for sorting in the category (hexadecimal string)',
322320 ' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)',
323321 ' type - Adds the type that the page has been categorised as (page, subcat or file)',
324322 ' timestamp - Adds the timestamp of when the page was included',
Property changes on: branches/wmf/1.17wmf1/includes/api/ApiQueryCategoryMembers.php
___________________________________________________________________
Modified: svn:mergeinfo
325323 Merged /trunk/phase3/includes/api/ApiQueryCategoryMembers.php:r86257
Index: branches/wmf/1.17wmf1/includes/api/ApiQueryCategories.php
@@ -66,7 +66,7 @@
6767 'cl_to'
6868 ) );
6969
70 - $this->addFieldsIf( 'cl_sortkey', isset( $prop['sortkey'] ) );
 70+ $this->addFieldsIf( array( 'cl_sortkey', 'cl_sortkey_prefix' ), isset( $prop['sortkey'] ) );
7171 $this->addFieldsIf( 'cl_timestamp', isset( $prop['timestamp'] ) );
7272
7373 $this->addTables( 'categorylinks' );
@@ -147,7 +147,8 @@
148148 $vals = array();
149149 ApiQueryBase::addTitleInfo( $vals, $title );
150150 if ( isset( $prop['sortkey'] ) ) {
151 - $vals['sortkey'] = $row->cl_sortkey;
 151+ $vals['sortkey'] = bin2hex( $row->cl_sortkey );
 152+ $vals['sortkeyprefix'] = $row->cl_sortkey_prefix;
152153 }
153154 if ( isset( $prop['timestamp'] ) ) {
154155 $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
@@ -215,7 +216,7 @@
216217 return array(
217218 'prop' => array(
218219 'Which additional properties to get for each category',
219 - ' sortkey - Adds the sortkey for the category',
 220+ ' sortkey - Adds the sortkey (hexadecimal string) and sortkey prefix (human-readable part) for the category',
220221 ' timestamp - Adds timestamp of when the category was added',
221222 ' hidden - Tags categories that are hidden with __HIDDENCAT__',
222223 ),

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86257API: BREAKING CHANGE: (bug 28541) Output of binary ICU sortkeys is broken. Ch...catrope12:41, 17 April 2011

Status & tagging log