Page MenuHomePhabricator

Delete edit recovery data after 30 days
Closed, ResolvedPublicFeature

Description

Feature summary:

When saving any page, that page's edit recovery data is deleted. This is a good point at which to also delete any out of date data for other pages.

Pages have a lastModified field in their recovery data, which can be used to determine the last time a page was opened for editing. If a page hasn't been opened for editing within 30 days, its data should be deleted.

Acceptance criteria:

  • Pages that have not been edited for 30 days are removed from the edit recovery indexedDB storage.

Use cases:

  • As a user, I don't want my browser's storage filling up with unwanted recovery data for pages that I've not edited in a long time.

QA notes:

QA Results - Local

Event Timeline

I would recommend implementing a generic expiry API, like we did with localStorage in T121646.

Yes, definitely a good idea. I've been investigating doing that, and it has been a bit of a trade off between building something now for this use case, and building a framework that could work for future use cases as well (without actually knowing what those are, at the moment — which is why I've hesitated so far).

We'll look at moving the generic bits of the storage layer to a central place e.g. mediawiki.indexedDB. mw.storage has an optional expiry, but we could make it mandatory probably.

mw.storage has an optional expiry, but we could make it mandatory probably.

Yes - it's only optional for backwards compatibility.

Change 958986 had a related patch set uploaded (by Samtar; author: Samtar):

[mediawiki/core@master] editRecovery: Delete edit recovery data after 30 days

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

Change 958986 merged by jenkins-bot:

[mediawiki/core@master] editRecovery: Delete edit recovery data after 30 days

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

@Samwilson @TheresNoTime I have created https://phabricator.wikimedia.org/T348593 to have it configurable in LocalSettings.php since this expiration date is hard coded. I did change it to 1 day so I should be able to test tomorrow afternoon, though is the key correct for the expiryDate?

Status: Pending
Environment: Local: 1.42.0-alpha (a985465) 10:25, 10 October 2023
OS: macOS Sonoma 14.0
Browser: Chrome 117
Device: MBA M2
Emulated Device:: n/a
Test Links:
http://localhost:8080/w/index.php?title=Harry_potter&action=edit

❓AC1: https://phabricator.wikimedia.org/T341956

2023-10-10_15-28-59.png (1×3 px, 992 KB)

@GMikesell-WMF Thanks! That's a good idea to make it configurable.

The key is correct for expiryDate, it's the unix timestamp of the expiry time.

@Samwilson @TheresNoTime The data did not get removed as seen in the gif. I will move this to Needs attention for now. I will also set up another test article just so I have two, just in case. They both now have an expiry date of 1697180400 which is set up for today at midnight in case you figure out why it's not deleting the data in the indexDB.

Status: ❌ FAIL
Environment: Local: 1.42.0-alpha (a985465) 10:25, 10 October 2023
OS: macOS Sonoma 14.0
Browser: Chrome 117
Device: MBA M2
Emulated Device:: n/a
Test Links:
http://localhost:8080/w/index.php?title=Harry_potter&action=edit
http://localhost:8080/w/index.php?title=Beer&action=edit

❌AC1: https://phabricator.wikimedia.org/T345315

2023-10-12_08-43-27.mp4.gif (1×3 px, 1 MB)

I set up another article to test as seen in the screenshot.

2023-10-12_09-57-54.png (1×3 px, 1 MB)

I did change it to 1 day so I should be able to test tomorrow afternoon

If you move your system clock forward a day this should have the same effect.

I did change it to 1 day so I should be able to test tomorrow afternoon

If you move your system clock forward a day this should have the same effect.

That's also true, thanks!

It looks like after closing the tab and opening up a new one, it looks like it just moves the expiryDate a day after again besides deleting it when comparing this screenshot and last.

2023-10-13_09-26-43.png (1×3 px, 628 KB)

Latest patch for T348593#9402563 should resolve these issues and unblock QA for this :-) 🤞

Without understanding the context fully, it seems odd that we'd keep edit recovery for 30 days. How realistic is it for a user to write edits, go on vacation, and come back and see their unsaved edits. Are we incurring significant tech debt or effort to keep this data for 30 days? How might this change if the rule were 30 minutes, 1 hour, 24 hours?

It's a good question. I think basically we started with the idea that we're not allowed to store for more than 90 days, and so somewhat arbitrarily chose 30 days as a good time length. It's governed by a configuration variable $wgEditRecoveryExpiry and so can easily be changed at any time without a problem (although existing items' expiry dates won't be updated), and there's no code changes that we'd want to make if it was 1 day or 90.

I think that at least 7 days would be good. Personally, in Phabricator (where there's a similar feature) I often come back weeks later and am glad to find my in-progress words.

dom_walden subscribed.

I have tested that Edit Recovery data is expired in WikiEditor on Firefox and Chromium, CodeMirror on Chromium and CodeEditor on Firefox. For each of these three editors, I tested expiry in the case of editing, viewing preview and viewing changes, for both editing a whole page and editing a section.

I also tested for each editor that while undoing an edit or viewing an old edit data was not expired, because in these cases Edit Recovery is disabled (see T347867 and T347869). The only exception is when viewing the preview or changes for an undo, where Edit Recovery is enabled and data will be expired. This bug has been reported in T347869 and will be fixed there.

I couldn't test on Safari as I can only test this change locally and I don't have access to Safari locally.

Without understanding the context fully, it seems odd that we'd keep edit recovery for 30 days. How realistic is it for a user to write edits, go on vacation, and come back and see their unsaved edits. Are we incurring significant tech debt or effort to keep this data for 30 days? How might this change if the rule were 30 minutes, 1 hour, 24 hours?

I believe there is a limit to the amount of data a browser will store in IndexedDB (see https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quotas_and_eviction_criteria). I don't know how likely users are to hit that limit. However, I have not yet tested what happens when they do.

Test environment: local docker MediaWiki 1.42.0-alpha (9e9d76a) 05:04, 22 January 2024.

Ok. 30 days sounds reasonable so long as there isn't additional tech debt.