Don't regenerate raw sortkeys in CategoryPage.php
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 8 Mar 2011 20:49:35 +0000 (20:49 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 8 Mar 2011 20:49:35 +0000 (20:49 +0000)
Previously, when adding pages, we'd use $title->getCategorySortkey(
$row->cl_sortkey_prefix ) to generate the initial letter on category
pages.  This is fine if the migration script has already been run, but
until then, cl_sortkey_prefix will always be the empty string, so the
user-specified sortkey will be ignored when generating initial letters.
Plus, if getCategorySortkey() had nontrivial computational cost, this
would be a waste of resources.

So just use $row->cl_sortkey instead.  This is at least guaranteed to be
consistent with how pagination works, no matter what state the DB is in.

Already deployed by Roan to fix user bug reports in #wikimedia-tech,
from apergos, Alpha_Quadrant, and Romaine.  Tested on Wikimedia, so far
so good.

includes/CategoryPage.php

index a5fbe8e..5b96a1d 100644 (file)
@@ -360,7 +360,7 @@ class CategoryViewer {
                        $count = 0;
                        foreach ( $res as $row ) {
                                $title = Title::newFromRow( $row );
-                               $rawSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
+                               $rawSortkey = $row->cl_sortkey;
 
                                if ( ++$count > $this->limit ) {
                                        # We've reached the one extra which shows that there