Opened 7 years ago
Last modified 5 years ago
#43760 new enhancement
Create a revision when autosaving if the content has changed significantly
Reported by: | azaozz | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Autosave | Keywords: | has-patch needs-testing has-unit-tests 2nd-opinion |
Focuses: | Cc: |
Description
Sometimes a user may edit a post for hours without saving it. We have autosaves to prevent any data loss. However in some cases there may be an user or a server error and the content may not be submitted or the post may be "empty". This doesn't happen often, but is usually devastating for the users. They just lost hours of work!
To safeguard against these cases, we can create post revisions when the autosave data is significantly different than the existing post.
Attachments (2)
Change History (8)
#2
@
7 years ago
- Keywords has-unit-tests added
Interesting.
43760.1.diff is my version for a diff-based implementation instead. Just as an idea with some tests that can also be repurposed for your patch.
Also, a suggestion on the wp_create_revision_for_autosave
filter: I think should send in the $post_data
and $autosave_data
, the count probably useless as users would be using their own heuristics.
Thoughts?
#3
@
5 years ago
- Keywords 2nd-opinion added
- Milestone changed from Future Release to 5.3
@soulseekah thanks for the alternate patch. Yeah, using text diff will be more precise but slower, and since this will always run in the background, making it a bit slower wouldn't matter.
However counting lines may be somehow problematic. It is possible to have all of post_content on one line which would mean lots of revisions with minimal changes. Thinking we should be counting something else, perhaps number of changed places + size of changes, or just added + deleted characters.
Also thinking it would be good to keep the "sliding scale" based on string length of post_content. So for longer posts the percentage of changes would be less. That will catch vases like having a post with 10 paragraphs and adding another one, vs. having a post with 3 paragraphs and editing few words in one of them.
Also perhaps the wp_create_revision_for_autosave_threshold
that filters the percentage of changes needed to trigger a revision may be a bit of overkill? Plugins that would want to look there will be able to do everything they need by using the wp_create_revision_for_autosave
filter.
Lets try to add that in 5.3 :)
diff-based implementation