Page MenuHomePhabricator

Unpredictable behaviour when undoing from error
Open, LowPublicBUG REPORT

Description

What is the problem?

If clicking the "Transcribe text" button leads to an error, clicking "Undo transcription" can lead to undesirable results, such as:

  • the wikitext is completely cleared or replaced by "null" (see screenshot)
  • an older edit of the wikitext is restored

When a request to transcribe the text is made and is successful we save the current contents of the wikitext editor, before replacing it, so we can restore it using undo.

If the request is unsuccessful, clicking undo will restore the wikitext from the last successful transcription request. If any edits had been made in the meantime, these will be lost. If this happens to be the first transcription request, there will be no saved wikitext and the textarea will be replaced by an empty string or null.

Perhaps we should not allow people to undo after an error. We don't change the wikitext if the transcription request returns an error, so there is no need to undo.

Steps to reproduce problem
  1. In Firefox, open https://en.wikisource.org/w/index.php?title=Page:Prevention_of_Bribery_Ordinance_1970_(Cap._201).pdf/19&action=edit
  2. Open devtools and go to the Network tab
  3. Open Request Blocking (circled in red in the screenshot below)
  4. In the input labelled "Block resource when URL contains" enter: https://ocr.wmcloud.org/
  5. Click "Transcript text"
  6. Click "Undo transcription"

Expected behavior: The wikitext is not changed.
Observed behavior: The wikitext is cleared.

Environment

Environment: Wikisource – (ee7fe53) 06:44, 12 August 2022.

Screenshots

undo_error.png (1×1 px, 547 KB)

Event Timeline

Change #1130725 had a related patch set uploaded (by Osuji pius; author: Osuji pius):

[mediawiki/extensions/Wikisource@master] hide undo widget if transcription fails

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

@Osuji_pius: Thanks; please avoid duplicate notifications; see previous comment here

Change #1131461 had a related patch set uploaded (by Aklapper; author: Nidhicodes):

[mediawiki/extensions/Wikisource@master] Fix: Prevent undo from clearing wikitext after failed OCR

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

Change #1130725 had a related patch set uploaded (by Osuji pius; author: Osuji pius):

[mediawiki/extensions/Wikisource@master] hide undo widget if transcription fails

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

@Samwilson @theprotonade
please for the above issue. Should the undo widget be completely hidden when transcription fails or should the widget still be present but inactive

Change #1133914 had a related patch set uploaded (by Dorcasbd; author: Dorcasbd):

[mediawiki/extensions/Wikisource@master] ExtractTextWidget: Enhance OCR error handling and undo widget state

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

Hello @Samwilson @theprotonade @Soda

I'm Dorcas Bamisile, an outreachy applicant.

I have just pushed a change for this issue. Could you kindly review it?

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

Thank you!

Change #1135853 had a related patch set uploaded (by Vicolas11; author: Vicolas11):

[mediawiki/extensions/Wikisource@master] Hide undo option when no text or error occurs

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

Hello @Samwilson @theprotonade @Soda

My name is Victor Akoh, an outreachy 2025 applicant. I just made a push to this task. Please kindly review it. Thanks.

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikisource/+/1135853

Please do not duplicate notifications, see the comment by @gerritbot right before - thanks!

This comment was removed by Osuji_pius.

Change #1130725 merged by jenkins-bot:

[mediawiki/extensions/Wikisource@master] hide undo widget if transcription fails

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