* Given a string, convert it to a (hopefully short) key that can be used
* for efficient sorting. A binary sort according to the sortkeys
* corresponds to a logical sort of the corresponding strings. Current
- * code expects that a null character should sort before all others, but
+ * code expects that a line feed character should sort before all others, but
* has no other particular expectations (and that one can be changed if
* necessary).
*
}
function getSortKey( $string ) {
+ // intl extension produces non null-terminated
+ // strings. Appending '' fixes it so that it doesn't generate
+ // a warning on each access in debug php.
wfSuppressWarnings();
$key = $this->mainCollator->getSortKey( $string ) . '';
wfRestoreWarnings();
public function getCategorySortkey( $prefix = '' ) {
$unprefixed = $this->getText();
if ( $prefix !== '' ) {
- # Separate with a null byte, so the unprefixed part is only used as
- # a tiebreaker when two pages have the exact same prefix -- null
- # sorts before everything else (hopefully).
+ # Separate with a line feed, so the unprefixed part is only used as
+ # a tiebreaker when two pages have the exact same prefix.
+ # In UCA, tab is the only character that can sort above LF
+ # so we strip both of them from the original prefix.
$prefix = strtr( $prefix, "\n\t", ' ' );
return "$prefix\n$unprefixed";
}