Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -123,7 +123,6 @@ |
124 | 124 | $this->addOption( 'USE INDEX', 'cl_timestamp' ); |
125 | 125 | } else { |
126 | 126 | if ( $params['continue'] ) { |
127 | | - // type|from|sortkey |
128 | 127 | $cont = explode( '|', $params['continue'], 3 ); |
129 | 128 | if ( count( $cont ) != 3 ) { |
130 | 129 | $this->dieUsage( 'Invalid continue param. You should pass the original value returned '. |
— | — | @@ -136,8 +135,9 @@ |
137 | 136 | $queryTypes = array_slice( $queryTypes, $contTypeIndex ); |
138 | 137 | |
139 | 138 | // Add a WHERE clause for sortkey and from |
140 | | - $from = intval( $cont[1] ); |
141 | | - $escSortkey = $this->getDB()->addQuotes( $cont[2] ); |
| 139 | + // pack( "H*", $foo ) is used to convert hex back to binary |
| 140 | + $escSortkey = $this->getDB()->addQuotes( pack( "H*", $cont[1] ) ); |
| 141 | + $from = intval( $cont[2] ); |
142 | 142 | $op = $dir == 'newer' ? '>' : '<'; |
143 | 143 | // $contWhere is used further down |
144 | 144 | $contWhere = "cl_sortkey $op $escSortkey OR " . |
— | — | @@ -197,12 +197,9 @@ |
198 | 198 | if ( $params['sort'] == 'timestamp' ) { |
199 | 199 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); |
200 | 200 | } else { |
201 | | - // Continue format is type|from|sortkey |
202 | | - // The order is a bit weird but it's convenient to put the sortkey at the end |
203 | | - // because we don't have to worry about pipes in the sortkey that way |
204 | | - // (and type and from can't contain pipes anyway) |
| 201 | + $sortkey = bin2hex( $row->cl_sortkey ); |
205 | 202 | $this->setContinueEnumParameter( 'continue', |
206 | | - "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}" |
| 203 | + "{$row->cl_type}|$sortkey|{$row->cl_from}" |
207 | 204 | ); |
208 | 205 | } |
209 | 206 | break; |
— | — | @@ -226,7 +223,7 @@ |
227 | 224 | ApiQueryBase::addTitleInfo( $vals, $title ); |
228 | 225 | } |
229 | 226 | if ( $fld_sortkey ) { |
230 | | - $vals['sortkey'] = $row->cl_sortkey; |
| 227 | + $vals['sortkey'] = bin2hex( $row->cl_sortkey ); |
231 | 228 | } |
232 | 229 | if ( $fld_sortkeyprefix ) { |
233 | 230 | $vals['sortkeyprefix'] = $row->cl_sortkey_prefix; |
— | — | @@ -243,8 +240,9 @@ |
244 | 241 | if ( $params['sort'] == 'timestamp' ) { |
245 | 242 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); |
246 | 243 | } else { |
| 244 | + $sortkey = bin2hex( $row->cl_sortkey ); |
247 | 245 | $this->setContinueEnumParameter( 'continue', |
248 | | - "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}" |
| 246 | + "{$row->cl_type}|$sortkey|{$row->cl_from}" |
249 | 247 | ); |
250 | 248 | } |
251 | 249 | break; |
— | — | @@ -336,7 +334,7 @@ |
337 | 335 | 'What pieces of information to include', |
338 | 336 | ' ids - Adds the page ID', |
339 | 337 | ' title - Adds the title and namespace ID of the page', |
340 | | - ' sortkey - Adds the sortkey used for sorting in the category (may not be human-readble)', |
| 338 | + ' sortkey - Adds the sortkey used for sorting in the category (hexadecimal string)', |
341 | 339 | ' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)', |
342 | 340 | ' type - Adds the type that the page has been categorised as (page, subcat or file)', |
343 | 341 | ' timestamp - Adds the timestamp of when the page was included', |
Index: trunk/phase3/includes/api/ApiQueryCategories.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | 'cl_to' |
72 | 72 | ) ); |
73 | 73 | |
74 | | - $this->addFieldsIf( 'cl_sortkey', isset( $prop['sortkey'] ) ); |
| 74 | + $this->addFieldsIf( array( 'cl_sortkey', 'cl_sortkey_prefix' ), isset( $prop['sortkey'] ) ); |
75 | 75 | $this->addFieldsIf( 'cl_timestamp', isset( $prop['timestamp'] ) ); |
76 | 76 | |
77 | 77 | $this->addTables( 'categorylinks' ); |
— | — | @@ -151,7 +151,8 @@ |
152 | 152 | $vals = array(); |
153 | 153 | ApiQueryBase::addTitleInfo( $vals, $title ); |
154 | 154 | if ( isset( $prop['sortkey'] ) ) { |
155 | | - $vals['sortkey'] = $row->cl_sortkey; |
| 155 | + $vals['sortkey'] = bin2hex( $row->cl_sortkey ); |
| 156 | + $vals['sortkeyprefix'] = $row->cl_sortkey_prefix; |
156 | 157 | } |
157 | 158 | if ( isset( $prop['timestamp'] ) ) { |
158 | 159 | $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp ); |
— | — | @@ -219,7 +220,7 @@ |
220 | 221 | return array( |
221 | 222 | 'prop' => array( |
222 | 223 | 'Which additional properties to get for each category', |
223 | | - ' sortkey - Adds the sortkey for the category', |
| 224 | + ' sortkey - Adds the sortkey (hexadecimal string) and sortkey prefix (human-readable part) for the category', |
224 | 225 | ' timestamp - Adds timestamp of when the category was added', |
225 | 226 | ' hidden - Tags categories that are hidden with __HIDDENCAT__', |
226 | 227 | ), |