Page MenuHomePhabricator

Main references are displayed incorrectly on svwiki (if they're not used in the article)
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

  • Create the following minimal wikitext:
<ref name="Test 1" details="P. 1">Main ref</ref>

== References ==
<references />

What happens?:

  • There are square brackets next to the main reference

Screenshot from 2026-02-24 18-17-29.png (180×173 px, 5 KB)

What should have happened instead?:

  • Display the main reference without square brackets

Screenshot from 2026-02-24 18-19-23.png (180×173 px, 4 KB)

Other information:

  • I believe sv:MediaWiki:Cite references link many is responsible. Swedish Wikipedia uses a customized version to put a b in squared brackets when references are re-used. See sv:Användare:Johannes Richter (WMDE)/sandlåda1 (or the screenshot below) for different examples.
  • If my assumption is correct the main reference might get recognized as re-used but without any backlink markers to put into square brackets (unless the main reference is used somewhere without sub-ref details).
  • We might want to check for similar customizations on other wikis.

Screenshot from 2026-02-24 18-15-48.png (1,016×483 px, 43 KB)

Event Timeline

I can confirm this is because of the customized cite_references_link_many message. The problem unique to sub-refs is that we are using this message to render a reference with zero backlinks. Before sub-refs have been introduced that message was only used for refs with two or more backlinks.

The part of the message that looks like ↑ $2 in the default message looks like ^ [$2] in the customized version. When the main ref is only used via sub-refs but never on its own we replace the $2 with nothing. This works with the default message but not with the customized version. The empty [] stay behind.

Collection of ideas we had so far:

  1. Introduce a new message for the new zero backlink scenario. However, this is possibly the worst solution because multiple teams are trying hard to get rid of these messages for years.
  2. Hard-code the HTML (in this one special case) without using any of the messages. Maybe use cite_reference_backlink_symbol so they can at least customize the up-arrow.
  3. Ask the community to add the missing <span class="mw-cite-backlink">…</span> to their message, and we strip that from our output when we know we don't want any backlinks. However, this would also strip the (plain text) up-arrow.
  4. We could hard-code a hack that specifically looks for the empty [] and removes it. That would work, but there is a high risk it would silently become a permanent solution. And there is a high risk it would block us (or whoever continues to work on the extension) later.
  5. Editing https://sv.wikipedia.org/wiki/MediaWiki:Cite_references_link_many and wrapping the brackets in {{#if:$2|<nowiki>[</nowiki>$2<nowiki>]</nowiki>}} actually works according to my local tests. Even in both parsers! The only disadvantage is that the message (something we would love to get rid of) becomes a bit more complicated (technically depends in ParserFunctions now). However, that's more a philosophical question, not really a fundamental new Technical-Debt.
  6. Can we convince the community to remove the brackets? That would solve the problem without any code change. They have been added in 2006 (see https://sv.wikipedia.org/wiki/MediaWiki:Cite_references_link_many?action=history) by an admin that is not active any more (see https://sv.wikipedia.org/wiki/Special:Bidrag/Daedalus).

Fixed by removing the brackets (onwiki discussion). We'll keep this task open to investigate if other wikis use similar customizations before approaching global rollout of sub-referencing.

Lina_Farid_WMDE claimed this task.

This bug is resolved. I'm closing it and will create a new task in our rollout epic.

Change #1245343 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Stop using cite_references_link_many message for zero backlinks

https://gerrit.wikimedia.org/r/1245343

We noticed that https://sv.wikipedia.org/wiki/MediaWiki:Gadget-referenser.css also introduces square brackets in Parsoid view. Proposed fix (consistent with the community removing the square brackets in MediaWiki:Cite references link many):

Change lines 14-19 from:

span[rel="mw:referencedBy"]::before {
    content: "^ [";
}
span[rel="mw:referencedBy"]::after {
    content: "]";
}

To:

span[rel="mw:referencedBy"]::before {
    content: "^ ";
}

-> Delete lines 17-19 entirely and remove the square bracket from line 15.

We noticed that https://sv.wikipedia.org/wiki/MediaWiki:Gadget-referenser.css also introduces square brackets in Parsoid view. Proposed fix (consistent with the community removing the square brackets in MediaWiki:Cite references link many):

Change lines 14-19 from:

span[rel="mw:referencedBy"]::before {
    content: "^ [";
}
span[rel="mw:referencedBy"]::after {
    content: "]";
}

To:

span[rel="mw:referencedBy"]::before {
    content: "^ ";
}

-> Delete lines 17-19 entirely and remove the square bracket from line 15.

Needs a better solution because an svwiki admin added the brackets back to MediaWiki:Cite references link many (but went with the {{#if:$2|<nowiki>[</nowiki>$2<nowiki>]</nowiki>}} approach suggested by @thiemowmde) following a community discussion. The issue is still fixed in the default parser but not in Parsoid where simply removing the brackets from MediaWiki:Gadget-referenser.css would no longer lead to the identical result.

Change #1247440 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Remove empty backlink <span> from Parsoid output

https://gerrit.wikimedia.org/r/1247440

I looked into how the Parsoid problem could be solved. What comes to mind first is to adapt the community CSS in a similar way as in the legacy parser (i.e. only add the brackets when there actually are backlinks). While this might actually be solvable with the :empty selector (see MDN) I found a much more straightforward solution: https://gerrit.wikimedia.org/r/1247440

Change #1254112 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Cite@master] Remove not needed space from zero backlink formatter

https://gerrit.wikimedia.org/r/1254112

Change #1245343 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Stop using cite_references_link_many message for zero backlinks

https://gerrit.wikimedia.org/r/1245343

I'm afraid there is not much we can do when the community mushed two customizations (the ^ and the [) into one line of code. They should please edit their https://sv.wikipedia.org/wiki/MediaWiki:Gadget-referenser.css as follows.

Old
span[rel="mw:referencedBy"]::before {
    content: "^ [";
}
span[rel="mw:referencedBy"]::after {
    content: "]";
}
New
span[rel="mw:referencedBy"]::before {
    content: '^ ';
}
span[rel="mw:referencedBy"]:not(:empty)::before {
    content: '^ [';
}
span[rel="mw:referencedBy"]:not(:empty)::after {
    content: ']';
}

Change #1247440 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/extensions/Cite@master] Remove empty backlink <span> from Parsoid output

Reason:

Not possible as long as the rendering of the ↑ depends on this <span>.

https://gerrit.wikimedia.org/r/1247440

Change #1254112 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Remove not needed space from zero backlink formatter

https://gerrit.wikimedia.org/r/1254112