Opened 3 months ago

Last modified 7 weeks ago

#23665 new enhancement

Create one autosave per user

Reported by: azaozz Owned by:
Priority: normal Milestone: 3.6
Component: Autosave Version:
Severity: normal Keywords:
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 (6)

23665.patch (6.3 KB) - added by azaozz 3 months ago.
23665-2.patch (7.5 KB) - added by azaozz 3 months ago.
23665-post-name.patch (658 bytes) - added by azaozz 3 months ago.
23665-3.patch (12.9 KB) - added by azaozz 2 months ago.
23665-post-preview.patch (1.1 KB) - added by johnjamesjacoby 5 weeks ago.
Fix logic for generating post preview $url in post_preview()
23665-post-preview-2.patch (7.3 KB) - added by johnjamesjacoby 5 weeks 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.

Download all attachments as: .zip

Change History (13)

azaozz3 months ago

In 23631:

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

azaozz3 months ago

azaozz3 months 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. If we remove it, or remove it only for autosaves, we can run a different query to fetch only the autosaves for a post instead of looping through all revisions as in the other patch.

Last edited 3 months ago by azaozz (previous) (diff)

azaozz2 months ago

In 23665-3.patch:

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

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.

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

In 23889:

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

In 23890:

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

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

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.

Note: See TracTickets for help on using tickets.