Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State: Autosave should be treated as regular save for same-user draft post #7124

Closed
aduth opened this issue Jun 4, 2018 · 0 comments · Fixed by #7130
Closed

State: Autosave should be treated as regular save for same-user draft post #7124

aduth opened this issue Jun 4, 2018 · 0 comments · Fixed by #7130
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript REST API Interaction Related to REST API [Type] Task Issues or PRs that have been broken down into an individual action to take
Milestone

Comments

@aduth
Copy link
Member

aduth commented Jun 4, 2018

Related: #7122 (comment)

When an autosave occurs for an auto-draft or draft post authored by the same user, the server treats it as a regular save:

if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id ) {
// Draft posts for the same author: autosaving updates the post and does not create a revision.
// Convert the post object to an array and add slashes, wp_update_post expects escaped array.
$autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true );

This should also be respected in the client, meaning:

  • There should be no prompts for unsaved changes after this occurs
  • The post's "current" values, i.e. state.currentPost, should reflect anything included in the autosave request

A couple possible implementations may include:

  • Testing as a condition of the save effect to consider isAutosave as false when the autosave is draft for current user
  • Handling as a case in the currentPost reducer
  • Dispatch resetPost after autosave completes successfully, when autosave is draft for current user
@aduth aduth added [Type] Task Issues or PRs that have been broken down into an individual action to take Framework Issues related to broader framework topics, especially as it relates to javascript REST API Interaction Related to REST API labels Jun 4, 2018
@danielbachhuber danielbachhuber added this to the 3.1 milestone Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript REST API Interaction Related to REST API [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants