Page MenuHomePhabricator

Sortkey for categories is ignored when category is inside a <ref> and DEFAULTSORT comes after <references/>
Closed, ResolvedPublic

Description

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 T4700.


Version: unspecified
Severity: minor
URL: https://de.wikipedia.beta.wmflabs.org/wiki/Ref-sort

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:45 AM
bzimport added a project: Cite.
bzimport set Reference to bz38435.
bzimport added a subscriber: Unknown Object (MLST).

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.

Tacsipacsi added a project: MediaWiki-Parser.
Tacsipacsi added subscribers: Umherirrender, Tacsipacsi.

According to @Umherirrender, it’s not specific to Cite.

Change 983434 had a related patch set uploaded (by C. Scott Ananian; author: C. Scott Ananian):

[mediawiki/core@master] Substitute category default sort key when filling links table, not at parse time

https://gerrit.wikimedia.org/r/983434

Change #983434 merged by jenkins-bot:

[mediawiki/core@master] Substitute category default sort key when filling links table, not at parse time

https://gerrit.wikimedia.org/r/983434

Being a decade-old bug, I think it’s newsworthy that it has been fixed (draft added to Tech/News/2024/16).

Being a decade-old bug, I think it’s newsworthy that it has been fixed (draft added to Tech/News/2024/16).

Thanks for adding it to Tech News.

Change #1020865 had a related patch set uploaded (by Arlolra; author: C. Scott Ananian):

[mediawiki/core@REL1_42] Substitute category default sort key when filling links table, not at parse time

https://gerrit.wikimedia.org/r/1020865

Change #1020865 merged by jenkins-bot:

[mediawiki/core@REL1_42] Substitute category default sort key when filling links table, not at parse time

https://gerrit.wikimedia.org/r/1020865

Pppery removed a project: Patch-For-Review.