WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#23665 closed enhancement (fixed)

Create one autosave per user

Reported by: azaozz Owned by: nacin
Milestone: 3.6 Priority: normal
Severity: normal Version:
Component: Autosave Keywords:
Focuses: Cc:

Description

Currently when autosaving drafts we overwrite them, when autosaving published posts, we keep one autosaved revision. This works well as long as there is only one post author.

Having per-user autosaves will affect only sites with many authors/editors. It will avoid overwriting when more than one user edits a post, provide better audit trail, and let us auto save data stored in the browser even if another user is editing at that moment.

Attachments (7)

23665.patch (6.3 KB) - added by azaozz 2 years ago.
23665-2.patch (7.5 KB) - added by azaozz 2 years ago.
23665-post-name.patch (658 bytes) - added by azaozz 2 years ago.
23665-3.patch (12.9 KB) - added by azaozz 2 years ago.
23665-post-preview.patch (1.1 KB) - added by johnjamesjacoby 2 years ago.
Fix logic for generating post preview $url in post_preview()
23665-post-preview-2.patch (7.3 KB) - added by johnjamesjacoby 2 years ago.
Introduce wp_get_preview_post_url() to funnel post-preview URL handling through, and replace in all instances. Also patches _set_preview() and moves _show_post_preview() to 'set_current_user' priority 20 instead.
23665.diff (827 bytes) - added by nacin 2 years ago.

Download all attachments as: .zip

Change History (17)

@azaozz2 years ago

comment:1 @nacin2 years ago

In 23631:

Use auto-draft rather than post_ID = 0 to detect whether we are adding a new post. see #23665.

@azaozz2 years ago

@azaozz2 years ago

comment:2 @azaozz2 years ago

In 23665-2.patch​:

  • Don't short-circuit wp_get_post_revisions() when WP_POST_REVISIONS is false. It is used to get the autosave(s) too.
  • Show the correct preview to each user when several users are editing.

23665-post-name.patch​ short-circuits wp_unique_post_slug() for post revisions. Currently revisions are saved with post_name {$post->post_parent}-revision, and autosaves: {$post->post_parent}-autosave. When there are more than one, wp_unique-post_slug kicks in and adds -2, -3, etc. to the end. This is intended for post slugs and not necessary for revisions.

Version 0, edited 2 years ago by azaozz (next)

@azaozz2 years ago

comment:3 @azaozz2 years ago

In 23665-3.patch:

  • Update wp_ajax_autosave() removing post locks references.
  • Update autosave.js removing post locks and logged out warnings.

comment:4 @azaozz2 years ago

In 23735:

Create one autosave per user rather than a single autosave for all users. Remove unused code from autosave.js and wp_ajax_autosave(). See #23665.

comment:5 @azaozz2 years ago

In 23830:

Fix wp_list_post_revisions() to include all autosaves when listing autosaves only and properly include or exclude the current post, see #23665, see #16215

comment:6 @nacin2 years ago

In 23889:

No need to check for the presence of a current user in a privileged ajax action. see #23665.

comment:7 @nacin2 years ago

In 23890:

Replace $user_id removed in [23889] with a direct function call. see #23665.

@johnjamesjacoby2 years ago

Fix logic for generating post preview $url in post_preview()

@johnjamesjacoby2 years ago

Introduce wp_get_preview_post_url() to funnel post-preview URL handling through, and replace in all instances. Also patches _set_preview() and moves _show_post_preview() to 'set_current_user' priority 20 instead.

comment:8 @nacin2 years ago

Other than the following, I think this is fixed.

todo: Needs review. The errors generated in WP_Ajax_Response and parsed with wpAjax.parseAjaxResponse() haven't been used for years.

azaozz?

comment:9 @azaozz2 years ago

Generally autosave needs a refresh/refactoring. WP_Ajax_Response and wpAjax.parseAjaxResponse() pass errors coming from WP_Error when saving a post. For autosave these used to be displayed under the editor. That was removed/hidden couple of years ago. As far as I remember the reason was that these are intermittent "dead-end" errors and the user cannot do anything to fix them. These errors used to be somewhat more common when we had negative post_id (before auto-draft was implemented).

Currently if there is error when saving the post, the message "Saving Draft..." that is shown while waiting for the autosave response, is not updated. Although this is not a regression it probably should be fixed. Instead of the "Draft saved at..." message we could show the actual error or perhaps just "Autosave error".

@nacin2 years ago

comment:10 @nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 24651:

Modify todo in wp_ajax_autosave(). fixes #23665.

Note: See TracTickets for help on using tickets.