Last modified: 2014-06-23 13:47:46 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 20707 - Nested refs fail inside references block
Nested refs fail inside references block
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Cite (Other open bugs)
All All
: Normal major with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on: 1310
  Show dependency treegraph
Reported: 2009-09-18 01:41 UTC by Robert Rohde
Modified: 2014-06-23 13:47 UTC (History)
10 users (show)

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


Description Robert Rohde 2009-09-18 01:41:58 UTC
By design, Cite does not allow a <ref> to appear within another <ref>.  (This is probably a result of parser design and concerns over maintaining the integrity of Cite's internal data stack.)

However, clever Wikipedians realized that one can use #tag to avoid Cite's design limitations and create functional nested references such as:

AAA {{#tag:ref| BBB <ref> CCC </ref> }}

(See also: Bug 16330)

Recently, Cite was expanded to allow reference content to be defined within a references block, i.e.

Foo <ref name="bar"/>

<ref name="bar">blah blah</ref>

While most references work fine in this context, the #tag based nested ref constructions universally fail when moved inside <references>.  Depending on the number and order of #tag calls used and the depth of the stack the result will either be an uninformative error message or a misnumbered reference list.

The solution to this is probably to create an implementation that generically supports nested refs.  (Part of the problem is that Cite was not intended to allow for nested refs at all and though the #tag based hack worked previously because of quirks in parser behavior, the same call structure doesn't work when moved inside the references block.)

The "right" way to do this is probably to restructure Cite's internal data stack and change the way the evaluation of references are hooked into the parser.  I will probably implement this myself eventually, though probably not for some months.
Comment 1 Ruslan 2009-09-20 18:18:40 UTC
An obvious solution to this problem is to use {{#tag:references|...}} construct.
Comment 2 Robert Rohde 2009-09-20 19:16:58 UTC
(In reply to comment #1)
> An obvious solution to this problem is to use {{#tag:references|...}}
> construct.

Apparently one can define a nested ref inside a #tag:references as long as both the portions of the nest are also defined by #tag.

Based on an example by Ruslik_Zero:

AAAA<ref name="note1" group="note" />
== notes ==
{{#tag:ref|foo{{#tag:ref|inside ref}}bar|group="note"|name="note1"}}

== references ==
<references />

Frankly, I'm surprised that even that works, but it will fail if any of those three #tag calls is replaced by a normal invocation.  Hence I would say this is a rather fragile work around.
Comment 3 Gadget850 2010-05-11 14:27:44 UTC
I suspect this is the same issue that causes problems with #tag:ref in list defined references. A single use works, but more than one results in Cite error: <ref> tag defined in <references> has no name attribute.


<ref group=Note name=a />
<ref group=Note name=b />
<ref group=Note name=c />



Nesting #tag:ref does not work either:

Comment 4 Platonides 2010-05-22 15:07:22 UTC
Also see bug 22635
Comment 5 Platonides 2010-05-22 15:08:35 UTC
*** Bug 22300 has been marked as a duplicate of this bug. ***
Comment 6 athenurlauber 2010-08-13 12:48:01 UTC
A reflist containing both a plain ref tag and a "#tag:" ref tag with a nested ref tag in it works if the ref-in-a-ref is listed before the plain ref, and doesn't work if the ref-in-a-ref is listed after the plain ref (demo here

This works:

text<ref name=n1 group=nested_first/>
text<ref name=n2 group=nested_first/>.

;Reflist, nested ref listed first:{{reflist|group=nested_first|refs=

{{#tag:ref|With nested reference<ref>content
of nested reference</ref>|name=n1|group=nested_first}}

<ref name=n2 group=nested_first>With no nested reference</ref>

;Nested refs:

This not:

text<ref name=n3 group=nested_second/>
text<ref name=n4 group=nested_second/>.

;Reflist, nested ref listed second:{{reflist|group=nested_second|refs=

<ref name=n3 group=nested_second>With no nested reference</ref>

{{#tag:ref|With nested reference<ref>content
of nested reference</ref>|name=n4|group=nested_second}}

;Nested refs:
Comment 7 Gadget850 2011-10-06 13:24:31 UTC
Here is the working sample from above without templates.

Placing <ref name=n2> first throws a "Cite error references no text" and a "Cite error references no key".

Using #tag:ref more than once in the list throws the errors.

text<ref name=n1 group=nested_first/>
text<ref name=n2 group=nested_first/>.



{{#tag:ref|With nested reference<ref>content
of nested reference</ref>|name=n1}}

<ref name=n2>With no nested reference</ref>



<references />

I consider this the most egregious issue with cite.php. The inability to easily add a reference to an explanatory note using cite.php has caused the creation and retention of multiple templates for this purpose. In use, most of these templates create duplicate ids, thus rendering invalid HTML and bad in-page linking.

The simplest fix from the user standpoint would be to allow <ref> tags to nest, while allowing the #tag:ref hack to still work. Note that many uses of #tag:ref have multiple embedded <refs>s. If we have to add new syntax, then we can deal with it.

There is no expectation of multiple nesting, i.e. stuffing a #tag:ref inside a #tag:ref.

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