(bug 28540) revert r83544 - It really breaks things when using uca-default collation...
authorBrian Wolff <bawolff@users.mediawiki.org>
Thu, 14 Apr 2011 23:28:11 +0000 (23:28 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Thu, 14 Apr 2011 23:28:11 +0000 (23:28 +0000)
Various functions (particuarly the getFirstCharacter ones) all expect to have the human readable sortkey.
Passing them the binary sortkey results in the getFirstChar headers to be totally wrong. It also
causes paging not to work since the sortkey gets double encoded.

This issue probably wasn't noticed, since it wouldn't be visible on the uppercase collation
as uppercasing the first letter won't affect the first character headings, nor does double uppercasing
something matter.

Also changed one of the variable names from $rawSortkey to $humanSortkey as it confused me
(raw as in before turning to binary, or raw as in the real non-human readable sortkey)

includes/CategoryPage.php

index a8cae43..f252ac0 100644 (file)
@@ -244,7 +244,7 @@ class CategoryViewer {
        * else use sortkey...
        *
        * @param Title $title
-       * @param string $sortkey
+       * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever).
        */
        function getSubcategorySortChar( $title, $sortkey ) {
                global $wgContLang;
@@ -364,22 +364,22 @@ class CategoryViewer {
                        $count = 0;
                        foreach ( $res as $row ) {
                                $title = Title::newFromRow( $row );
-                               $rawSortkey = $row->cl_sortkey;
+                               $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
 
                                if ( ++$count > $this->limit ) {
                                        # We've reached the one extra which shows that there
                                        # are additional pages to be had. Stop here...
-                                       $this->nextPage[$type] = $rawSortkey;
+                                       $this->nextPage[$type] = $humanSortkey;
                                        break;
                                }
 
                                if ( $title->getNamespace() == NS_CATEGORY ) {
                                        $cat = Category::newFromRow( $row, $title );
-                                       $this->addSubcategoryObject( $cat, $rawSortkey, $row->page_len );
+                                       $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
                                } elseif ( $title->getNamespace() == NS_FILE ) {
-                                       $this->addImage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
+                                       $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
                                } else {
-                                       $this->addPage( $title, $rawSortkey, $row->page_len, $row->page_is_redirect );
+                                       $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
                                }
                        }
                }