Page MenuHomePhabricator

False duplicate errors ("defined multiple times with different content") when using {{#tag:ref}} with XML-style tags inside
Open, MediumPublic

Description

Cite emits false duplicate errors when using {{#tag:ref}} with XML-style tags inside. For example:

{{#tag:ref|<nowiki>foo</nowiki>|name=foo}}
{{#tag:ref|<nowiki>foo</nowiki>|name=foo}}
<references />

This is because, due to using #tag, the Cite extension doesn't look at the original wikitext as written above, but only after the XML-style tags have been replaced by strip markers.

While the example above is better written as the following, which doesn't cause the issue:

<ref name=foo><nowiki>foo</nowiki></ref>
<ref name=foo><nowiki>foo</nowiki></ref>
<references />

…this problem is impossible to avoid when nesting <ref> tags (which is bad but people do it anyway, often without realizing it due to templates like {{sfn}}), which is only possible with {{#tag}}:

<ref name="Buna">Advance to Buna</ref>
{{#tag:ref|Buna<ref name=Buna />|name=Blakeley}}
{{#tag:ref|Buna<ref name=Buna />|name=Blakeley}}
<references />

Event Timeline

matmarex raised the priority of this task from to Needs Triage.
matmarex updated the task description. (Show Details)
matmarex added a project: Cite.
matmarex added subscribers: matmarex, PrimeHunter.

This Error cause a lot of trouble in de.wikisource. It isn't possible for us to avoid these errors.

I made a couple edits to a couple of templates (e.g. https://de.wikisource.org/w/index.php?title=Vorlage:SeiteST&diff=prev&oldid=2529412) and I think I managed to fix many of the broken pages with this - https://de.wikisource.org/wiki/Kategorie:Seiten_mit_Referenzierungsfehlern is down to 45 pages now (it used to have 70).

I can't figure out some others, though - no idea why https://de.wikisource.org/wiki/Seite:David_Hilbert_Gesammelte_Abhandlungen_Bd_1.djvu/93 is getting the error, for example.

matmarex added a subscriber: Bawolff.

@Bawolff suggested that we could call unstripBoth() to replace the strip markers with real content before comparing. I'll try that.

A reduced example of the syntax that is causing the error in the David Hilbert thing:

{{#tag:ref| foo {{#tag:ref|bar|name=bar}} | name=foo }}
{{#tag:ref| foo {{#tag:ref|bar|name=bar}} | name=foo }}
<references/>
matmarex triaged this task as Medium priority.Jan 8 2016, 12:30 AM

@Bawolff suggested that we could call unstripBoth() to replace the strip markers with real content before comparing. I'll try that.

Well, that doesn't work. The real content differs because each occurrence has a different id, to allow backlinks.

The David Hilbert thing is actually different, on closer look, more like this:

{{#tag:ref| foo {{#tag:ref|bar}} | name=foo }}
{{#tag:ref| foo {{#tag:ref|bar}} | name=foo }}
<references/>

(The inner refs have no name.) This still doesn't work, as they still have different id (more obviously even). If you look at https://de.wikisource.org/wiki/Seite:David_Hilbert_Gesammelte_Abhandlungen_Bd_1.djvu/93#Anmerkungen_.28Wikisource.29, sure enough, references 5 and 7 are duplicated and identical.

I think this is impossible to fix without a serious time expenditure, and I do not have any more time to expend on it :(

@THE_IT Sorry about that. I can recommend doing one of two things at Wikisource:

a) Restructure the templates to not generate the ref contents more than once. Something like this:

{{#tag:ref| foo {{#tag:ref|bar}} | name=foo }}
{{#tag:ref||name=foo}}
<references/>

I don't think I can help with this, the templates seem really messy and I don't speak German, making any debugging more difficult.

b) Just suppress the error message, if you have few of the actual errors. Edit "MediaWiki:Cite error references duplicate key" to be empty, and edit "MediaWiki:Cite error" to produce no output when $1 is empty (something like {{#if:$1|Cite error: $1}}).

This will still add the tracking category, but it'll get rid of the nasty error messages from the pages.

@matmarex: Thanks for your help. I applied your suggestions. This fix the big red errors for the moment. But still is there an error in the cite extension in my opinion.

But still is there an error in the cite extension in my opinion.

Yeah, I agree. But it is still difficult to fix ;) Cite wasn't written with nested references in mind, eh.