Last modified: 2014-09-24 01:22:22 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T4802, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 2802 - Display more than one character of the sort key
Display more than one character of the sort key
Product: MediaWiki
Classification: Unclassified
Categories (Other open bugs)
All All
: Low enhancement with 4 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-reviewed
Depends on:
  Show dependency treegraph
Reported: 2005-07-11 16:42 UTC by ThomasV
Modified: 2014-09-24 01:22 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Here is an actual patch. it works with 1.5beta3 (910 bytes, patch)
2005-07-12 16:01 UTC, ThomasV
patch generated with diff -u. (1.00 KB, patch)
2005-07-12 16:23 UTC, ThomasV
new patch for utf8 strings (1.60 KB, patch)
2005-07-18 16:57 UTC, ThomasV
ok, new patch using firstChar. (1.29 KB, patch)
2005-07-19 10:08 UTC, ThomasV

Description ThomasV 2005-07-11 16:42:02 UTC
If all articles in a given category have sort keys that begin with the same
letter, only this letter will be displayed when the category is rendered. It
would be better to display more letters, until sort keys are different. 

The following patch determines the length of the longest common substring, and
it displays this length+1 characters. I was tested with mediawiki 1.4.

Proposed patch: In file CategoryPage.php, around line 137, replace existing code

				// Page in this category
				array_push( $articles, $sk->makeKnownLinkObj( $title ) ) ;
				array_push( $articles_start_char, $x->cl_sortkey )  ;
		$root_length = 0;
		for ($index = 0 ; $index < count($articles) - 1; $index++){
				if($index == count($articles) - 2)	{
				  $root_length = $root_length+1;
		for ($index = 0 ; $index < count($articles) ; $index++){		
			$articles_start_char[$index] =

		$dbr->freeResult( $res );
Comment 1 ThomasV 2005-07-12 16:01:21 UTC
Created attachment 700 [details]
Here is an actual patch. it works with 1.5beta3
Comment 2 ThomasV 2005-07-12 16:23:30 UTC
Created attachment 701 [details]
patch generated with diff -u. 

patch for 1.5beta3. 

also, minor fix: $index has to be reset to -1 inside the loop (was 0)
Comment 3 Ævar Arnfjörð Bjarmason 2005-07-12 18:29:16 UTC
(In reply to comment #2)
> Created an attachment (id=701) [edit]
> patch generated with diff -u. 
> patch for 1.5beta3. 
> also, minor fix: $index has to be reset to -1 inside the loop (was 0)

Applied to HEAD after some fixes, namely using $wgContLang->truncate() instead
of substr() and formatting.

Marking this as FIXED.
Comment 4 Brion Vibber 2005-07-14 05:47:07 UTC
This fix caused bug 2835, so I've backed out the change (revision 1.24 of CategoryPage.php).

Comment 5 ThomasV 2005-07-18 16:57:19 UTC
Created attachment 727 [details]
new patch for utf8 strings

the regression was caused by incorrect handling of utf8 strings.
it should be fixed with this new patch. 
(I *know* this code is ugly. please bear with me)
Comment 6 Brion Vibber 2005-07-18 17:06:39 UTC
it might be better to use the firstChar() and trim() methods on Language, to avoid duplicating ugly UTF-8 code.
Comment 7 ThomasV 2005-07-19 10:08:35 UTC
Created attachment 731 [details]
ok, new patch using firstChar. 

I hope ugliness went down to an acceptable level, 
although I don't see how to use trim here.
Comment 8 Max Semenik 2009-08-09 10:31:52 UTC
rm need-review, the patch is obsolete.
Comment 9 Happy-melon 2011-03-30 23:01:55 UTC
Is this rendered obsolete by the 1.17 collation rewrite?
Comment 10 Aryeh Gregor (not reading bugmail, please e-mail directly) 2011-03-31 22:42:27 UTC
The patch might not apply anymore, but the bug is certainly still relevant.
Comment 11 Sumana Harihareswara 2011-11-10 02:58:38 UTC
ThomasV, if you're interested in updating your patch to work with current trunk, please join us in the #mediawiki channel on freenode IRC to ask for feedback and discuss your approach.  Thanks!
Comment 12 Bawolff (Brian Wolff) 2011-11-10 17:25:08 UTC
btw, a while back I made an extension that does something similar to what this bug requests (but not quite the same thing) - [[mw:extension:CategorySortHeaders]] in case anyone is interested.

Note You need to log in before you can comment on or make changes to this bug.