Issue:Mode=category loses letter headings when ordermethod=titlewithoutnamespace
Description: | mode=category should produce headings A, B, C, etc., but does not when ordermethod=titlewithoutnamespace |
Extension / Version: | DPL / 1.8.8 |
Type / Status: | Bug / open |
Problem
MediaWiki 1.15.1.
This produces the headings A, B, C, etc., like a category page:
<dpl> category = African Union member states mode = category ordermethod = title </dpl>
Example:
C
N
S
This should produce A, B, C, etc., but does not:
<dpl> category = African Union member states mode = category ordermethod = titlewithoutnamespace </dpl>
Example:
C
N
S
I think the headings are empty or blank, not missing. If you have many items in your list, you will see continuation headings like "cont." instead of "A cont." So I'm guessing the headings are being rendered, but they are blank, so nothing shows up. Here is an example with "cont.":
"
%
A
- Issue:A problem in the conbination DPL 1.7.4 and MW1.3 using Chinense interface
- Issue:AddContribution missing prefix
- Issue:AddContribution missing prefix regression
- Issue:Add "minimum-number-of-revisions" like Criteria for page selection
- Issue:Add a template in the pages automatically by DPL
- Issue:Add new option to exclude page sections
- Issue:Addlasteditor crashes new article
Patch
In this situation, when ordermethod=titlewithoutnamespace, DPLArticle->mStartChar is not being set. This is happening because in DPLMain.php, formatCategoryList() says:
if( isset($row->sortkey) ) { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($row->sortkey)); }
but $row->sortkey is not set. I changed it to
if( isset($row->sortkey) ) { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($row->sortkey)); } else { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($row->page_title)); }
and things seem to work. What do you think of this patch? It looks like mStartChar is unused in DPL, except for category mode, so this should be pretty safe...?
Better code:
$startChar = isset($row->sortkey) ? $row->sortkey : $row->page_title; $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($startChar));
Any comments on this patch? Maiden taiwan 19:43, 4 February 2010 (UTC)
Notes on the patch
Looks like this bug is gone in DPL 2.0 (prerelease). However, the code in DPLMain.php looks like it was patched incorrectly. Instead of replacing the old code, my patch was placed after the old code, so you now have this:
if( isset($row->sortkey) ) { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($row->sortkey)); } if( isset($row->sortkey) ) { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($row->sortkey)); } else { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($pageTitle)); }
which redundantly tests isset($row->sortkey
twice and sets $dplArticle->mStartChar
twice.
(Also note: the extra indenting is misleading: both IF statements are actually at the same indent level.)
The code should be:
if( isset($row->sortkey) ) { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($row->sortkey)); } else { $dplArticle->mStartChar = $wgContLang->convert($wgContLang->firstChar($pageTitle)); }