Last modified: 2013-02-15 14:40:59 UTC
See URL for an example. The source is like this: Text<ref>[[Category:Test]]</ref>[[Category:Test2]] <references /> {{DEFAULTSORT:Sortkey}} Expected result: In both categories the article should be put under S. Actual result: Only in Category:Test2 the article is under S, in Category:Test it is sorted as its title says. When you put the DEFAULTSORT before the <references/> it works as expected. I don't know how this is handled internally, so this could be just a duplicate of bug 2700.
The problem exist also for tags of core: <gallery>File:Wiki.png|desc[[Category:Test]]</gallery> {{DEFAULTSORT:Sortkey}} category links are added when the wikilinks are handled, for tags this is done within the tag processing because tags always return html. At this point the defaultsort is maybe not set and the category gets an empty sortkey, which than result in the page name as default. A solution is to look for the old defaultsort at the already added categories when setting the new defaultsort, but that will also change the custom sortkey, when he is equal to the old defaultsort. Need some extra doing at the end of the parse.
*** Bug 44676 has been marked as a duplicate of this bug. ***
Even if this may seem like something that will only rarely occur in a Wiki environment, it does indeed happen quite often as soon as templates (for database weblinks, literature etc.) are used in references that add maintenance categories for missing data etc.