Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -5072,15 +5072,19 @@ |
5073 | 5073 | |
5074 | 5074 | /** |
5075 | 5075 | * Accessor for $mDefaultSort |
5076 | | - * Will use the title/prefixed title if none is set |
| 5076 | + * Will use the empty string if none is set. |
5077 | 5077 | * |
| 5078 | + * This value is treated as a prefix, so the |
| 5079 | + * empty string is equivalent to sorting by |
| 5080 | + * page name. |
| 5081 | + * |
5078 | 5082 | * @return string |
5079 | 5083 | */ |
5080 | 5084 | public function getDefaultSort() { |
5081 | 5085 | if ( $this->mDefaultSort !== false ) { |
5082 | 5086 | return $this->mDefaultSort; |
5083 | 5087 | } else { |
5084 | | - return $this->mTitle->getCategorySortkey(); |
| 5088 | + return ''; |
5085 | 5089 | } |
5086 | 5090 | } |
5087 | 5091 | |
Index: trunk/phase3/includes/LinksUpdate.php |
— | — | @@ -72,7 +72,10 @@ |
73 | 73 | # it truncated by DB, and then doesn't get |
74 | 74 | # matched when comparing existing vs current |
75 | 75 | # categories, causing bug 25254. |
76 | | - $sortkey = substr( $sortkey, 0, 255 ); |
| 76 | + # Also. substr behaves weird when given "". |
| 77 | + if ( $sortkey !== '' ) { |
| 78 | + $sortkey = substr( $sortkey, 0, 255 ); |
| 79 | + } |
77 | 80 | } |
78 | 81 | |
79 | 82 | $this->mRecursive = $recursive; |
— | — | @@ -435,7 +438,7 @@ |
436 | 439 | global $wgContLang, $wgCategoryCollation; |
437 | 440 | $diffs = array_diff_assoc( $this->mCategories, $existing ); |
438 | 441 | $arr = array(); |
439 | | - foreach ( $diffs as $name => $sortkey ) { |
| 442 | + foreach ( $diffs as $name => $prefix ) { |
440 | 443 | $nt = Title::makeTitleSafe( NS_CATEGORY, $name ); |
441 | 444 | $wgContLang->findVariantLink( $name, $nt, true ); |
442 | 445 | |
— | — | @@ -447,23 +450,12 @@ |
448 | 451 | $type = 'page'; |
449 | 452 | } |
450 | 453 | |
451 | | - # TODO: This is kind of wrong, because someone might set a sort |
452 | | - # key prefix that's the same as the default sortkey for the |
453 | | - # title. This should be fixed by refactoring code to replace |
454 | | - # $sortkey in this array by a prefix, but it's basically harmless |
455 | | - # (Title::moveTo() has had the same issue for a long time). |
456 | | - if ( $this->mTitle->getCategorySortkey() == $sortkey ) { |
457 | | - $prefix = ''; |
458 | | - $sortkey = Collation::singleton()->getSortKey( $sortkey ); |
459 | | - } else { |
460 | | - # Treat custom sortkeys as a prefix, so that if multiple |
461 | | - # things are forced to sort as '*' or something, they'll |
462 | | - # sort properly in the category rather than in page_id |
463 | | - # order or such. |
464 | | - $prefix = $sortkey; |
465 | | - $sortkey = Collation::singleton()->getSortKey( |
466 | | - $this->mTitle->getCategorySortkey( $prefix ) ); |
467 | | - } |
| 454 | + # Treat custom sortkeys as a prefix, so that if multiple |
| 455 | + # things are forced to sort as '*' or something, they'll |
| 456 | + # sort properly in the category rather than in page_id |
| 457 | + # order or such. |
| 458 | + $sortkey = Collation::singleton()->getSortKey( |
| 459 | + $this->mTitle->getCategorySortkey( $prefix ) ); |
468 | 460 | |
469 | 461 | $arr[] = array( |
470 | 462 | 'cl_from' => $this->mId, |
— | — | @@ -699,11 +691,7 @@ |
700 | 692 | array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions ); |
701 | 693 | $arr = array(); |
702 | 694 | foreach ( $res as $row ) { |
703 | | - if ( $row->cl_sortkey_prefix !== '' ) { |
704 | | - $arr[$row->cl_to] = $row->cl_sortkey_prefix; |
705 | | - } else { |
706 | | - $arr[$row->cl_to] = $this->mTitle->getCategorySortkey(); |
707 | | - } |
| 695 | + $arr[$row->cl_to] = $row->cl_sortkey_prefix; |
708 | 696 | } |
709 | 697 | return $arr; |
710 | 698 | } |