Page MenuHomePhabricator

Check and fix error reporting on merged sub-refs
Closed, ResolvedPublic

Description

In T385666: Show references with the same details as re-use in the legacy rendering (Merge Use Case) we implemented a first version (in the legacy parser) for how identical sub-references can be merged a.k.a. "reused". This is a very new code path with a very new merge mechanism, different from how main refs can be reused.

We need to make sure this new code path doesn't break existing, well-defined behaviors. Or if it does, that we are fine with the new (emergent) behavior.

Affected edge-case:

  • How should dir="rtl" behave on an identical sub-ref when it conflicts with the same attribute on a previous sub-ref, or the same attribute on the main ref?
    • Works as expected in the legacy parser because the relevant check happens earlier than the merge.
    • We might want to block the dir=… attribute entirely on a ref like <ref name="a" details="p. 2" dir="rtl" /> when there is no main content it could apply to. Is this worth it?
  • Check Parsoid for the edge case above: no error is displayed
  • follow= should already fail when used together with details=, so probably doesn't cause new problems here.
    • As expected.
  • Check Parsoid for the edge case above: error is displayed next to subref & marker is rendered - this differs from legacy
  • Let's say there are two identical <ref name="a" details="p. 2">The book</ref> with identical details, but one with a typo in the main content. Does this typo still cause the expected error?
    • Works as expected in the legacy parser because the relevant check happens earlier than the merge.
  • Check Parsoid for the edge case above: Other than in legacy the error shows up next to the subref and not next to the mainref.

We also need make sure all these cases behave the same in both parsers.

Patch-For-Review:

Open questions

  • Should Parsoid also display errors next to the main ref?
  • Do we want to block the dir attribute when used together with details?
  • Should we not render a marker and display an error when details and follow are being used together?

Event Timeline

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

[mediawiki/extensions/Cite@master] Move sub-ref merging in legacy parser out of dev-only branch

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

Change #1196401 had a related patch set uploaded (by Adarsh2406; author: Adarsh2406):

[mediawiki/extensions/Cite@master] Warn on conflicting dir when duplicate sub-refs are merged

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

Change #1196401 abandoned by Adarsh2406:

[mediawiki/extensions/Cite@master] Warn on conflicting dir when duplicate sub-refs are merged

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

Change #1196399 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Move sub-ref merging in legacy parser out of dev-only branch

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

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

[mediawiki/extensions/Cite@master] Fix incomplete error message on conflicting main content

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

The 2nd and 3rd case appear to (mostly) work in Parsoid. I found a few edge-cases, though:

  • Using details and follow together is a fatal in the old parser (which means we refuse to render the ref at all), but a warning in Parsoid (it's still successfully rendered as a sub-ref, just with the error message attached). Tracked in T400890.
  • It looks like there is no error message at all when a ref follows itself. Example: <ref name="x" details="x">a</ref> <ref name="x" details="x" follow="x" />
  • It appears like the dir attribute never renders an error message in Parsoid.

Change #1217144 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Fix incomplete error message on conflicting main content

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