Last modified: 2012-04-13 00:32:53 UTC
If CITE_DEFAULT_GROUP of set to 'Note' (for example) Cite will produce decimal footnotes [1], [2] instead of the expected [Note 1], [Note 2]. In fact you will be able to produce any footnote except [Note 1] etc... This doesn't happen when CITE_DEFAULT_GROUP is set to a group for which there is a MediaWiki:Cite link label group- set.
Created attachment 10373 [details] respect CITE_DEFAULT_GROUP + and allow optional decimal footnotes where default is something else Here's a patch. The problem was in the linkRef function wfMsgForContentNoTrans( 'cite_reference_link', $this->refKey( $key, $count ), $this->referencesKey( $key . $subkey ), $this->getLinkLabel( $label, $group, ( ( $group == CITE_DEFAULT_GROUP ) ? '' : "$group " ) . $wgContLang->formatNum( $label ) ) ) where instead of CITE_DEFAULT_GROUP there should be an empty string. I've made a few more changes however. In order to preserve the ability of editors to use decimal footnotes on site which have not decimal footnotes set as default, I've renamed them from '' (empty-string) to 'decimal'. A side-effect of this is to remove the present ability to separate sets of decimal footnotes on the same page: at present <ref>...</ref> is a separate group from <ref group="decimal">...</ref>
Thanks for the patch, bluehairedlawyer. By the way, you can get developer access https://www.mediawiki.org/wiki/Developer_access so you can just put this diff directly into our source control system as a merge request, for easier reviewing.
Could you add parser tests for this change? http://www.mediawiki.org/wiki/Parser_tests The file you would need to modify is CiteParserTests.txt https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Cite.git;a=history;f=citeParserTests.txt;hb=master
(In reply to comment #1) > respect CITE_DEFAULT_GROUP + and allow optional decimal footnotes where default > is something else > > Here's a patch. > > The problem was in the linkRef function That code has been there since group addition in 448a99da (March 2008) > where instead of CITE_DEFAULT_GROUP there should be an empty string. CITE_DEFAULT_GROUP *is* an empty string (just in the form of a constant). What do you mean by setting CITE_DEFAULT_GROUP ?
Created attachment 10404 [details] respect CITE_DEFAULT_GROUP + and allow optional decimal footnotes where default is something else (v2) In reply to comment #4: You can set CITE_DEFAULT_GROUP by including the following lines in your LocalSettings.php file in this order: define( 'CITE_DEFAULT_GROUP', 'lower-roman' ); require_once("$IP/extensions/Cite/Cite.php"); (I'm assuming this is an intended feature for wikis which prefer not to have decimal footnotes – ie [1], [2], [3] – by default.) This example currently works assuming you have a file at: MediaWiki:Cite_link_label_group-lower-roman However if you set it to 'note', you don't get the (IMHO) expected [Note 1], [Note 2], [Note 3] footnotes. You get [1], [2], [3] footnotes. This is the fist bug. In addition there is a second bug: if a wiki decides to have non-decimal footnotes by default it becomes difficult to opt-for decimal footnotes on page by page basis. If CITE_DEFAULT_GROUP is set to lower-roman, an editor who wishes to have [1], [2], [3] footnotes must either: * set his footnotes to empty string group ie <ref group="">...</ref>, or * create a page at MediaWiki:Cite_link_label_group-decimal like the one currently at enwiki (en.wikipedia.org/wiki/MediaWiki:Cite_link_label_group-decimal) and use the syntax <ref group="decimal">...</ref>, although this is hardly ideal. In reply to comment #3: I'm not sure about the possibility of adding parser tests as replicating the bug requires changing the value of CITE_DEFAULT_GROUP which breaks the current parser tests. However the attached patch does now manage to pass all the current parser tests.
> You can set CITE_DEFAULT_GROUP by including the following lines in your > LocalSettings.php file in this order: > > define( 'CITE_DEFAULT_GROUP', 'lower-roman' ); > require_once("$IP/extensions/Cite/Cite.php"); > > (I'm assuming this is an intended feature for wikis which prefer not to have > decimal footnotes – ie [1], [2], [3] – by default.) I don't think it's an intended feature, since you would be getting PHP Notice: Constant CITE_DEFAULT_GROUP already defined in Cite.php on line 37 Is that documented anywhere? > This example currently works assuming you have a file at: > > MediaWiki:Cite_link_label_group-lower-roman CITE_DEFAULT_GROUP predates Cite_link_label_group-<xyz> by 2 years, and no intention of custom CITE_DEFAULT_GROUP was done on creating them at d9b8f32959 > I'm not sure about the possibility of adding parser tests as replicating the > bug requires changing the value of CITE_DEFAULT_GROUP which breaks the current > parser tests. However the attached patch does now manage to pass all the > current parser tests. If it were to be implemented, it should have been a variable. You're relying on undocumented behavior.
-:) I guess that's probably why it didn't work!