Page MenuHomePhabricator

Regression: Cannot change main content of main+details
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

Main ref content is not changed in diff. No changes after save either.

What should have happened instead?:

Should see applied changes.

EditChangeAppliedNo changes in diff
obraz.png (296×514 px, 17 KB)
obraz.png (450×507 px, 24 KB)
obraz.png (269×409 px, 14 KB)
obraz.png (299×556 px, 17 KB)

Event Timeline

We can reproduce this bug, thanks for the report! Minor note, that the "section" steps seem to be unnecessary. We'll update the steps to reproduce as we learn more.

awight renamed this task from VE: Unable to edit reference with details defined in a section to Regression: Cannot change main content of main+details.Oct 1 2025, 10:02 AM
awight added a project: Regression.
awight updated the task description. (Show Details)
awight triaged this task as High priority.Oct 1 2025, 11:26 AM

Debugging notes

We see that ve.dm.MWReferenceNode#toDomElements correctly returns the new body content in data-mw.body.html, but it also connects to a data-mw.body.id:

<sup typeof="mw:Extension/ref" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;main&quot;},&quot;body&quot;:{&quot;id&quot;:&quot;mw-reference-text-cite_note-main-1&quot;,&quot;html&quot;:&quot;New main body&quot;},&quot;isSyntheticMainRef&quot;:1}" class="mw-ref reference"><a><span class="mw-reflink-text"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></span></a></sup>

The ref node points to the ID mw-reference-text-cite_note-main-1, which lives in the references list. The output of ve.dm.MWReferencesListNode#toDomElements correctly contains only "New main body" and never "Original main body" under this element and in the data-mw:

<div typeof="mw:Extension/references" data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{},&quot;autoGenerated&quot;:true,&quot;body&quot;:{&quot;html&quot;:&quot;\\n&lt;sup typeof=\\&quot;mw:Extension/ref\\&quot; data-mw=\\&quot;{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;main&amp;quot;},&amp;quot;body&amp;quot;:{&amp;quot;id&amp;quot;:&amp;quot;mw-reference-text-cite_note-main-1&amp;quot;,&amp;quot;html&amp;quot;:&amp;quot;New main body&amp;quot;},&amp;quot;isSyntheticMainRef&amp;quot;:1}\\&quot; class=\\&quot;mw-ref reference\\&quot; data-parsoid=\\&quot;{}\\&quot;&gt;&lt;a&gt;&lt;span class=\\&quot;mw-reflink-text\\&quot;&gt;&lt;span class=\\&quot;cite-bracket\\&quot;&gt;[&lt;/span&gt;1&lt;span class=\\&quot;cite-bracket\\&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/sup&gt;&quot;}}"><ol><li><span typeof="mw:Extension/ref" id="mw-reference-text-cite_note-main-1">New main body</span><ol><li><span typeof="mw:Extension/ref" id="mw-reference-text-cite_note-2">p. 1</span></li></ol></li></ol></div>

(Side note: the duplicated content is expected and can be explained here. The "synthetic list-defined" formulation buried under the reference list's data-mw holds the authoritative content of the internal item, and is the only place that sufficient RDFa is included for transforming back to wikitext. The plain DOM element ol.li.span only contains the HTML rendering and does not include RDFa. We have discussed tweaking the output and plan to fix through long-term maintenance.)

It becomes very mysterious how "Original main body" is making its way into this document at all. Intercepting the visualeditoredit API POST (docs) and decoding the base64+deflate, we can see a html field holding the serialized document, correctly showing only "New main body"!:

<!doctype html><html prefix="dc: http://purl.org/dc/terms/ mw: http://mediawiki.org/rdf/" about="http://dev.wiki.local.wmftest.net:8080/wiki/Special:Redirect/revision/78"><head prefix="mwr: http://dev.wiki.local.wmftest.net:8080/wiki/Special:Redirect/"><meta charset="utf-8"><meta property="mw:pageId" content="20"><meta property="mw:pageNamespace" content="0"><link rel="dc:replaces" resource="mwr:revision/0"><meta property="mw:revisionSHA1" content="bb1a56115f1251d128274aebb3ebbed2efb08727"><meta property="dc:modified" content="2025-10-01T11:04:57.000Z"><meta property="mw:htmlVersion" content="2.8.0"><meta property="mw:html:version" content="2.8.0"><link rel="dc:isVersionOf" href="http://dev.wiki.local.wmftest.net:8080/wiki/T406002"><base href="http://dev.wiki.local.wmftest.net:8080/wiki/"><title>T406002</title><meta property="mw:generalModules" content="ext.cite.ux-enhancements"><meta property="mw:moduleStyles" content="ext.cite.parsoid.styles|ext.cite.styles"><link rel="stylesheet" href="/w/load.php?lang=en&amp;modules=ext.cite.parsoid.styles%7Cext.cite.styles%7Cmediawiki.skinning.content.parsoid%7Cmediawiki.skinning.interface%7Csite.styles&amp;only=styles&amp;skin=vector"><meta http-equiv="content-language" content="en"><meta http-equiv="vary" content="Accept, Accept-Language"></head><body lang="en" class="mw-content-ltr sitedir-ltr ltr mw-body-content parsoid-body mediawiki mw-parser-output" dir="ltr" data-mw-parsoid-version="0.22.0.0-alpha25" data-mw-html-version="2.8.0" id="mwAA"><p id="mwAg"><sup about="#mwt1" class="mw-ref reference" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;main&quot;,&quot;details&quot;:&quot;p. 1&quot;},&quot;body&quot;:{&quot;id&quot;:&quot;mw-reference-text-cite_note-2&quot;},&quot;mainRef&quot;:&quot;main&quot;,&quot;mainBody&quot;:&quot;mw-reference-text-cite_note-main-1&quot;,&quot;isSubRefWithMainBody&quot;:1}"><a href="./T406002#cite_note-2" id="mwAw"><span class="mw-reflink-text" id="mwBA"><span class="cite-bracket" id="mwBQ">[</span>1.1<span class="cite-bracket" id="mwBg">]</span></span></a></sup></p>
<div typeof="mw:Extension/references" data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{},&quot;autoGenerated&quot;:true,&quot;body&quot;:{&quot;html&quot;:&quot;\n&lt;sup typeof=\&quot;mw:Extension/ref\&quot; data-mw=\&quot;{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;main&amp;quot;},&amp;quot;body&amp;quot;:{&amp;quot;id&amp;quot;:&amp;quot;mw-reference-text-cite_note-main-1&amp;quot;,&amp;quot;html&amp;quot;:&amp;quot;New main body&amp;quot;},&amp;quot;isSyntheticMainRef&amp;quot;:1}\&quot; class=\&quot;mw-ref reference\&quot; data-parsoid=\&quot;{}\&quot;&gt;&lt;a&gt;&lt;span class=\&quot;mw-reflink-text\&quot;&gt;&lt;span class=\&quot;cite-bracket\&quot;&gt;[&lt;/span&gt;1&lt;span class=\&quot;cite-bracket\&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/sup&gt;&quot;}}"><ol><li><span typeof="mw:Extension/ref" id="mw-reference-text-cite_note-main-1">New main body</span><ol><li><span typeof="mw:Extension/ref" id="mw-reference-text-cite_note-2">p. 1</span></li></ol></li></ol></div></body></html>

Finding

The problem seems to be in Cite's Parsoid selective serialization integration, conflicting with the "synthetic list-defined main ref" mechanism. When the main part of a main+details is edited but the details are not, the Cite\Parsoid\RefTagHandler#diffHandler is only called once on the main+details ref and it sees that ( isset( $origDataMw->body->html ) && isset( $editedDataMw->body->html ) is not satisfied so it falls through to comparing elements retrieved from the DOM by ID, and compares identical subref footnote body content ("p. 1" in the minimal example).

What it should have done is to call the diffHandler on the synthetic main ref as well, which would trigger it to be reserialized from the new data coming from VE. Instead, it is reserialized from its old value.

It should be possible to write a parser test for this case, with a manual selser edit.

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

[mediawiki/extensions/Cite@master] [WIP] Demonstration of main+details failure to update

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

We now have a parser test (attached) that can exercise the bad code paths.

I added debug logging in Cite\Parsoid\ReferenceListTagHandler#diffHandler because we would expect to see a difference in the synthetic main ref. It shows that the old content is found in the edited reflist node, for unknown reasons. But even if the diff were correctly detected here, it's unclear how that would inform the reserialization of the main+details elsewhere in the document.

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

[mediawiki/extensions/Cite@master] [DNM] temporary debug logging for ref selser

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

Proposed fix is unsatisfactory but maybe good enough for the short term.

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

[mediawiki/extensions/Cite@wmf/1.45.0-wmf.21] Nasty fix for main ref change in main+details

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

Change #1192937 merged by jenkins-bot:

[mediawiki/extensions/Cite@master] Nasty fix for main ref change in main+details

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

Change #1193009 merged by jenkins-bot:

[mediawiki/extensions/Cite@wmf/1.45.0-wmf.21] Nasty fix for main ref change in main+details

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

Mentioned in SAL (#wikimedia-operations) [2025-10-02T08:06:37Z] <awight@deploy2002> Started scap sync-world: Backport for [[gerrit:1193024|Revert "Enable Wikifunctions client mode on Wiktionaries, Part III, and Incubator" (T406185 T397401 T401682)]], [[gerrit:1193022|UX changes for reference context item (T404690)]], [[gerrit:1193009|Nasty fix for main ref change in main+details (T406002)]]

Mentioned in SAL (#wikimedia-operations) [2025-10-02T08:34:11Z] <awight@deploy2002> awight, hashar: Backport for [[gerrit:1193024|Revert "Enable Wikifunctions client mode on Wiktionaries, Part III, and Incubator" (T406185 T397401 T401682)]], [[gerrit:1193022|UX changes for reference context item (T404690)]], [[gerrit:1193009|Nasty fix for main ref change in main+details (T406002)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verif

Mentioned in SAL (#wikimedia-operations) [2025-10-02T08:55:30Z] <awight@deploy2002> Finished scap sync-world: Backport for [[gerrit:1193024|Revert "Enable Wikifunctions client mode on Wiktionaries, Part III, and Incubator" (T406185 T397401 T401682)]], [[gerrit:1193022|UX changes for reference context item (T404690)]], [[gerrit:1193009|Nasty fix for main ref change in main+details (T406002)]] (duration: 48m 54s)

Tobi_WMDE_SW claimed this task.