Page MenuHomePhabricator

Fix selective serialization for subreferences
Closed, DeclinedPublic

Description

In T389363: Fix attribute order round-tripping for sub-references (dirty diff) we see that references like <ref name="a" details="b">c</ref> are scrambled by VE when saving the page, and the "name" attribute moves around. Our hypothesis is that this is caused by the name attribute being deleted on subrefs (to trigger unnamed ref logic), causing what looks like a changed attribute for selective serialization.

This subtask is to fix selective serialization detection on these refs, which will almost entirely reduce the impact of dirty diffs.

Steps to implement:

  • Write a test (probably for Converter, including document store) which shows how subrefs are reserialized even when there were no changes inside the ref.
  • Fix change detection, making sure that: editing outside a ref never triggers a change, but editing any part of a main+details triggers a reserialization, as dos editing any non-main part of a subref without the main content.

Steps to replicate the issue:

What happens?:
Lots of unrelated, dirty diffs are produced:

image.png (1,049×565 px, 65 KB)

What should have happened instead?:
Only the "a" was added, this should have been the only diff.

Event Timeline

Change #1189481 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Cite@master] [WIP] test for bad selective serialization of subrefs

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

awight removed awight as the assignee of this task.

The root issue was simpler than expected. Leaving the "name" attribute untouched seems to allow for safe round-tripping, and there's no longer a false positive in selser (or in VE equivalent behavior).