# it truncated by DB, and then doesn't get
# matched when comparing existing vs current
# categories, causing bug 25254.
- $sortkey = substr( $sortkey, 0, 255 );
+ # Also. substr behaves weird when given "".
+ if ( $sortkey !== '' ) {
+ $sortkey = substr( $sortkey, 0, 255 );
+ }
}
$this->mRecursive = $recursive;
global $wgContLang, $wgCategoryCollation;
$diffs = array_diff_assoc( $this->mCategories, $existing );
$arr = array();
- foreach ( $diffs as $name => $sortkey ) {
+ foreach ( $diffs as $name => $prefix ) {
$nt = Title::makeTitleSafe( NS_CATEGORY, $name );
$wgContLang->findVariantLink( $name, $nt, true );
$type = 'page';
}
- # TODO: This is kind of wrong, because someone might set a sort
- # key prefix that's the same as the default sortkey for the
- # title. This should be fixed by refactoring code to replace
- # $sortkey in this array by a prefix, but it's basically harmless
- # (Title::moveTo() has had the same issue for a long time).
- if ( $this->mTitle->getCategorySortkey() == $sortkey ) {
- $prefix = '';
- $sortkey = Collation::singleton()->getSortKey( $sortkey );
- } else {
- # Treat custom sortkeys as a prefix, so that if multiple
- # things are forced to sort as '*' or something, they'll
- # sort properly in the category rather than in page_id
- # order or such.
- $prefix = $sortkey;
- $sortkey = Collation::singleton()->getSortKey(
- $this->mTitle->getCategorySortkey( $prefix ) );
- }
+ # Treat custom sortkeys as a prefix, so that if multiple
+ # things are forced to sort as '*' or something, they'll
+ # sort properly in the category rather than in page_id
+ # order or such.
+ $sortkey = Collation::singleton()->getSortKey(
+ $this->mTitle->getCategorySortkey( $prefix ) );
$arr[] = array(
'cl_from' => $this->mId,
array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
$arr = array();
foreach ( $res as $row ) {
- if ( $row->cl_sortkey_prefix !== '' ) {
- $arr[$row->cl_to] = $row->cl_sortkey_prefix;
- } else {
- $arr[$row->cl_to] = $this->mTitle->getCategorySortkey();
- }
+ $arr[$row->cl_to] = $row->cl_sortkey_prefix;
}
return $arr;
}