Last modified: 2012-04-13 00:32:53 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 T37675, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35675 - Cite fails to properly respect CITE_DEFAULT_GROUP
Cite fails to properly respect CITE_DEFAULT_GROUP
Status: RESOLVED INVALID
Product: MediaWiki extensions
Classification: Unclassified
Cite (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-03 17:31 UTC by bluehairedlawyer
Modified: 2012-04-13 00:32 UTC (History)
3 users (show)

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


Attachments
respect CITE_DEFAULT_GROUP + and allow optional decimal footnotes where default is something else (971 bytes, patch)
2012-04-03 20:03 UTC, bluehairedlawyer
Details
respect CITE_DEFAULT_GROUP + and allow optional decimal footnotes where default is something else (v2) (1.68 KB, patch)
2012-04-11 15:09 UTC, bluehairedlawyer
Details

Description bluehairedlawyer 2012-04-03 17:31:14 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.
Comment 1 bluehairedlawyer 2012-04-03 20:03:40 UTC
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>
Comment 2 Sumana Harihareswara 2012-04-04 03:01:18 UTC
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.
Comment 3 Mark A. Hershberger 2012-04-04 14:39:05 UTC
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
Comment 4 Platonides 2012-04-10 14:30:47 UTC
(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 ?
Comment 5 bluehairedlawyer 2012-04-11 15:09:38 UTC
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.
Comment 6 Platonides 2012-04-12 21:09:26 UTC
> 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.
Comment 7 bluehairedlawyer 2012-04-13 00:21:24 UTC
-:) I guess that's probably why it didn't work!

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


Navigation
Links