'cl_to'
) );
- $this->addFieldsIf( 'cl_sortkey', isset( $prop['sortkey'] ) );
+ $this->addFieldsIf( array( 'cl_sortkey', 'cl_sortkey_prefix' ), isset( $prop['sortkey'] ) );
$this->addFieldsIf( 'cl_timestamp', isset( $prop['timestamp'] ) );
$this->addTables( 'categorylinks' );
$vals = array();
ApiQueryBase::addTitleInfo( $vals, $title );
if ( isset( $prop['sortkey'] ) ) {
- $vals['sortkey'] = $row->cl_sortkey;
+ $vals['sortkey'] = bin2hex( $row->cl_sortkey );
+ $vals['sortkeyprefix'] = $row->cl_sortkey_prefix;
}
if ( isset( $prop['timestamp'] ) ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
return array(
'prop' => array(
'Which additional properties to get for each category',
- ' sortkey - Adds the sortkey for the category',
+ ' sortkey - Adds the sortkey (hexadecimal string) and sortkey prefix (human-readable part) for the category',
' timestamp - Adds timestamp of when the category was added',
' hidden - Tags categories that are hidden with __HIDDENCAT__',
),
$this->addOption( 'USE INDEX', 'cl_timestamp' );
} else {
if ( $params['continue'] ) {
- // type|from|sortkey
$cont = explode( '|', $params['continue'], 3 );
if ( count( $cont ) != 3 ) {
$this->dieUsage( 'Invalid continue param. You should pass the original value returned '.
$queryTypes = array_slice( $queryTypes, $contTypeIndex );
// Add a WHERE clause for sortkey and from
- $from = intval( $cont[1] );
- $escSortkey = $this->getDB()->addQuotes( $cont[2] );
+ // pack( "H*", $foo ) is used to convert hex back to binary
+ $escSortkey = $this->getDB()->addQuotes( pack( "H*", $cont[1] ) );
+ $from = intval( $cont[2] );
$op = $dir == 'newer' ? '>' : '<';
// $contWhere is used further down
$contWhere = "cl_sortkey $op $escSortkey OR " .
if ( $params['sort'] == 'timestamp' ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
} else {
- // Continue format is type|from|sortkey
- // The order is a bit weird but it's convenient to put the sortkey at the end
- // because we don't have to worry about pipes in the sortkey that way
- // (and type and from can't contain pipes anyway)
+ $sortkey = bin2hex( $row->cl_sortkey );
$this->setContinueEnumParameter( 'continue',
- "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}"
+ "{$row->cl_type}|$sortkey|{$row->cl_from}"
);
}
break;
ApiQueryBase::addTitleInfo( $vals, $title );
}
if ( $fld_sortkey ) {
- $vals['sortkey'] = $row->cl_sortkey;
+ $vals['sortkey'] = bin2hex( $row->cl_sortkey );
}
if ( $fld_sortkeyprefix ) {
$vals['sortkeyprefix'] = $row->cl_sortkey_prefix;
if ( $params['sort'] == 'timestamp' ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
} else {
+ $sortkey = bin2hex( $row->cl_sortkey );
$this->setContinueEnumParameter( 'continue',
- "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}"
+ "{$row->cl_type}|$sortkey|{$row->cl_from}"
);
}
break;
'What pieces of information to include',
' ids - Adds the page ID',
' title - Adds the title and namespace ID of the page',
- ' sortkey - Adds the sortkey used for sorting in the category (may not be human-readble)',
+ ' sortkey - Adds the sortkey used for sorting in the category (hexadecimal string)',
' sortkeyprefix - Adds the sortkey prefix used for sorting in the category (human-readable part of the sortkey)',
' type - Adds the type that the page has been categorised as (page, subcat or file)',
' timestamp - Adds the timestamp of when the page was included',