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

Don't error if autosave runs and there are no changes to save #7347

Merged
merged 2 commits into from
Jun 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Don't error if autosave runs and there are no changes to save
  • Loading branch information
notnownikki committed Jun 18, 2018
commit 7e2bfe8e18bda364290161b612825cffeee6d525
2 changes: 1 addition & 1 deletion lib/class-wp-rest-autosaves-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function create_post_autosave( $post_data ) {

if ( ! $autosave_is_different ) {
wp_delete_post_revision( $old_autosave->ID );
return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.', 'gutenberg' ) );
return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.', 'gutenberg' ), array( 'status' => 200 ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 400 is more appropriate here than 200. We should return 400 from the REST API, and then have special handling in Gutenberg for a 400 from the autosaves endpoint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to 400, and handled this specific error in the REQUEST_POST_UPDATE_FAILURE effect.

}

/**
Expand Down