Last modified: 2013-04-12 22:28:38 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 T48291, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46291 - SelectCategory is overriding the Mediawiki {{DEFAULTSORT}} magic word
SelectCategory is overriding the Mediawiki {{DEFAULTSORT}} magic word
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
SelectCategory (Other open bugs)
unspecified
All All
: Normal major (vote)
: ---
Assigned To: Christian Boltz
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-18 16:56 UTC by Laurent Jauquier
Modified: 2013-04-12 22:28 UTC (History)
1 user (show)

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


Attachments

Description Laurent Jauquier 2013-03-18 16:56:31 UTC
Hi,

First sorry if I'm wrong because I'm not a real techie guy and as you will notice my English is not perfect.

I'm using an older version of this extension but I had a look at the current code and it seems that this is still the same.

The {{DEFAULTSORT}} magic word (which can be used to change the default sort key of a category (ex: "Ete" instead of "Été")) is being overridden by the extension.

The problem seems to be this line:

$default_sortkey = "|{{PAGENAME}}";

As far as I understand, this line forces the sort key to be equal to the page's title and makes it impossible to set a custom sortkey. This is really a big issue especially on non English-language wikis that use accented and other special characters.

Moreover I don't understand why you're manually adding this sortkey. If no sortkey is being set (ex: "[[Category:Examplename]]" instead of "[[Category:Examplename|Examplename]]"), the name of the category ("Examplename") will be used by default, won't it? I thought this was already a default feature of Mediawiki. Am I wrong?

Reference about the magic word:

http://www.mediawiki.org/wiki/Help:Magic_words#Technical_metadata (look for "DEFAULTSORT")
Comment 1 Christian Boltz 2013-04-12 22:28:38 UTC
The relevant code is:

    # default sort key is page name with stripped namespace name,
    # otherwise sorting is ugly.
    if( !$isUpload && $pageObj->mTitle->getNamespace() == NS_MAIN ) {
        $default_sortkey = "";                                                                                                                                          
    } else {
        $default_sortkey = "|{{PAGENAME}}";
    }

The "|{{PAGENAME}}" is only added for pages that are not in the main namespace (like file: or category:)

The reason for this probably is/was *)  (copied from http://www.mediawiki.org/wiki/Help:Categories#Sort_key )

    By default, a page is sorted within a category under the
    first letter of its full name _including the namespace_. 

In other words: all Template:* pages would be listed under "T".

It seems this changed with current MediaWiki versions - a short look at some random categories in Wikipedia and a wiki I maintain indicates that the default sorting is now by page title _without_ the namespace, but I'm not 100% sure. (Can someone confirm that? - also asked on http://www.mediawiki.org/wiki/Help_talk:Categories)

If you want to test, edit the code (SelectCategory_body.php around line 150). Please replace
        $default_sortkey = "|{{PAGENAME}}";
with
        $default_sortkey = "";
and tell me what happens ;-)


*) the code for this was added long time before I started to work on SelectCategory

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


Navigation
Links