Page MenuHomePhabricator

Investigate IndexedDB as a data store for the auto-save wish
Closed, ResolvedPublic

Description

Before we suggest to the community that purely client-side storage of autosaves is possible, we should confirm that

  • IndexeDB is allowed to be used within our compatibility policy; and
  • we don't want to support cross-device recovering.

Event Timeline

IndexedDB isn't used in MediaWiki core or extensions yet.

All Grade-A browsers support it with the exception of Safari 14, where there's a bug.

It seems likely that recovering edits that failed to save due to network outages is more important that recovering on different devices.

There is also the question of privacy of the local data, especially for shared devices. It looks like it'd be best to delete all autosaved data when a user logs out, but not when they log in (i.e. they might start editing a page while logged out, leave that page to log in, and then when returning to it would still have their edits).

The storage schema could have a few possibilities:

  • Each page would have a row, with attributes for page text, edit comment, base revision ID, last modified time.
  • Could be keyed by page title or ID, depending on how people expect recovery to work if a page has been moved in the time between saving and recovering.
  • When checking whether to recover, it'd check the base revision ID (if it doesn't match, tell the user and maybe show a diff; if it does then just load the text).
  • Storing full text of the current unsaved text would make comparisons etc. easier.
  • Periodic purging of old untouched data could be done based on the last modified time.
  • Database name would be prefixed with the wiki ID, the same as cookie names. The object store name would be anything as it'd be the only thing in the DB.
  • Page row would be deleted when a user clicks cancel, or after a page loads after saving (i.e. not when clicking save but on the postEdit hook).

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

[mediawiki/core@master] [WIP] Edit recovery feature using indexedDB

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

Test wiki created on Patch demo by HMonroy (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/b9f73463ef/w

Test wiki on Patch demo by HMonroy (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/b9f73463ef/w/

The discussions this week have solidified our decision that indexedDB is fine to use for this. I'll move the above patch to the actual work ticket T341844.