Page MenuHomePhabricator

References can get lost while editing under some circumstances
Open, Needs TriagePublic

Description

Steps to reproduce:

  1. Start creating an article in NWE.
  2. Write a<ref>foo</ref><ref>bar</ref>.
  3. Switch to visual mode.
  4. Delete the automatically generated list of references.
  5. Insert a list of references.
  6. Edit the first reference to "foofoo".
  7. Switch to source mode.

Expected:

a<ref>foofoo</ref><ref>bar</ref>
<references />

Actual:

a<ref>foofoo</ref>
<references />

Note that the second reference "bar" got lost. This shouldn't happen. (Note: These are the steps which I actually did in a real edit. There may be a simpler reproduction, so it might be possible to lose a reference even without switching between modes, or during editing an existing article.)

Event Timeline

Schnark created this task.Jun 20 2018, 7:49 AM
Restricted Application added a project: VisualEditor. · View Herald TranscriptJun 20 2018, 7:49 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Schnark updated the task description. (Show Details)Jun 20 2018, 7:51 AM

VE appears to be generating the correct HTML, so this must be a Parsoid issue.

<p id="mwAg">a<sup typeof="mw:Extension/ref" data-mw="{'name':'ref','body':{'id':'mw-reference-text-cite_note-1','html':'foofoofoo'},'attrs':{}}" class="mw-ref" about="#mwt3" id="cite_ref-1" rel="dc:references"><a href="./T197760#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup><sup about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw="{'name':'ref','body':{'id':'mw-reference-text-cite_note-2'},'attrs':{}}"><a href="./T197760#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup></p>

VE appears to be generating the correct HTML, so this must be a Parsoid issue.

<p id="mwAg">a<sup typeof="mw:Extension/ref" data-mw="{'name':'ref','body':{'id':'mw-reference-text-cite_note-1','html':'foofoofoo'},'attrs':{}}" class="mw-ref" about="#mwt3" id="cite_ref-1" rel="dc:references"><a href="./T197760#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup><sup about="#mwt4" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw="{'name':'ref','body':{'id':'mw-reference-text-cite_note-2'},'attrs':{}}"><a href="./T197760#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup></p>

@Esanders: The bar reference has an id to the references block. Can you dump the full HTML that includes that as well?

ssastry moved this task from Backlog to Non-Parsoid Tasks on the Parsoid board.Jun 26 2018, 3:08 PM

We realized this is not a Parsoid bug right now. It looks like this is happening because (a) <ref> tags have a pointer to HTML in the <references> block (b) when a <references> block is deleted, VE deletes the node and so the <ref> pointer is now a dangling pointer and Parsoid can no longer emit content for it anymore which is why it gets lost.

The solution here that VE will have to keep around the contents in a buffer somewhere and set a deleted flag which Parsoid can then use to strip the <references /> tag. This would require a change on the Parsoid end (to handle the deleted flag) that has to be deployed before VE's change is deployed.

Alternatively, VE would set the autoGenerated flag for the deleted references blocks (without actually deleting it) since current Cite semantics are that you cannot not have a references list if a page has ref tags.

Vvjjkkii renamed this task from References can get lost while editing under some circumstances to zlaaaaaaaa.Jul 1 2018, 1:02 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
ssastry renamed this task from zlaaaaaaaa to References can get lost while editing under some circumstances.Jul 1 2018, 3:15 AM
ssastry lowered the priority of this task from High to Normal.
ssastry updated the task description. (Show Details)

Yeah - fixing this in the current state is going to be a nightmare, and the situation only arises if the user deletes a ref list (very rare), so I'm tempted to wait until Parsoid have taken over more of the ref handling code before we re-visit this.

CommunityTechBot raised the priority of this task from Normal to Needs Triage.Jul 5 2018, 7:03 PM