Page MenuHomePhabricator

Edit Recovery interaction with browser data recovery
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

I have noticed a few times when clicking "Discard changes" in the Edit Recovery popup that the wikitext remains unchanged, rather than reverting to the current revision of the article.

It does clear the data from IndexedDB, although a user might not realise that this has been done if the wikitext has not changed.

I believe it is because my browser is recovering the unsaved edits I made before Edit Recovery does. I am guessing that makes Edit Recovery think my unsaved edits are the original state of the article. Therefore, clicking "Discard changes" does not restore the correct thing.

Times I have seen this:

  • When doing a "soft" refresh on Firefox
  • When closing and reopening a tab (with ctrl+shift+t) on Firefox
  • Restoring tabs after closing and reopening Firefox
  • Sometimes when restoring tabs after I have simulated a crash on Firefox (by doing kill on the process)

I have yet to see this on Chromium. I don't know about other browsers.

I am not sure what we want to do in this case and whether there may be other interactions between Edit Recovery and the browser's native data recovery.

Steps to reproduce problem
  1. In Firefox, open a new tab and go to https://en.wikipedia.beta.wmflabs.org/w/index.php?title=PhonosTest-211&action=edit
  2. Make an edit
  3. Close the tab
  4. Restore the tab (ctrl+shift+t)
  5. In the "Changes recovered" popup, click "Discard changes"

Expected behaviour: Wikitext is restored to the state it was in step 1.
Observed behaviour: Wikitext is not changed. The edit you made in step 2 remains.

Environment

Browser: Firefox 115 and 119.
Wiki(s): https://en.wikipedia.beta.wmflabs.org MediaWiki 1.42.0-alpha (b2d4fd5) 14:40, 22 November 2023.
Editor: WikiEditor 0.5.4 (68da956) 07:21, 22 November 2023.

QA Results - Beta & Local

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptNov 22 2023, 3:11 PM

Change 977828 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Edit Recovery: Reset form before saving original data

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

Change 980977 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/WikiEditor@master] Realtime Preview: also trigger on form.reset()

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

Change 977828 merged by jenkins-bot:

[mediawiki/core@master] Edit Recovery: Store better original form data

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

Change 980977 merged by jenkins-bot:

[mediawiki/extensions/WikiEditor@master] Realtime Preview: also trigger on form.reset()

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

This should now be fixed, as we've changed how we store the initial data of the form (for later restoration).

Part of this was to also change how we reset the form to the initial state, but as part of T353616 it looks like we need to change this back again. This shouldn't impact this bug, but I think this task should wait on QA until that one is sorted out. The outstanding change there is r/987029.

@Samwilson I am still able to reproduce this bug on Firefox on beta, but not locally.

Beta and production both have Cache-Control: private, which might be the difference.

Change 991951 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Edit Recovery: Use original data rather than re-reading current

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

I'm able to reproduce this now. I'm not sure what was going wrong before but it's reliably wrong for me everywhere now.

But yep, this seems to be a complete oversight on my part in 36c3fc1992f7cd0d01bd33c1ad3f34bdb22cad0e when switching back from using HTMLForm.reset() to discard the form values (for T353616), when I added in code to re-read the current form values โ€” even though there was already a variable called originalData right there waiting to be used.

I think you're right in that Firefox behaves differently when restoring cached form data (on re-opening windows) depending on the cache headers. But we want it to work the same always (which I think it now willโ€ฆ famous last words of course).

Change 991951 merged by Samtar:

[mediawiki/core@master] Edit Recovery: Use original data rather than re-reading current

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

@Samwilson Wikitext is restored to the original state when you click "Discard Changes" as seen in the webm's below. This will be moved to Done. Thanks for all your work!

*Status: โœ…PASS
Environment: Beta: 1.42.0-alpha (2b746c7; Local: 1.42.0-alpha (5781b45) 17:58, 26 February 2024
OS: macOS Sonoma 14.2.1
Browser: Firefox 123, Safari 17.3, Edge 122
Skins. Vector 2022
Device: MBA M2
Emulated Device:: n/a
Test Links:**
https://en.m.wikipedia.beta.wmflabs.org/wiki/Dog#
http://localhost:8080/w/index.php?title=Cat&action=edit

โœ…AC1: https://phabricator.wikimedia.org/T351821

Beta

FirefoxSafariEdge

Local

FirefoxSafariEdge