State: Avoid URL redirect for published post autosave #7067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7066
This pull request seeks to resolve an issue where the editor URL is replaced with an autosave ID when autosaves occur for published posts. Since autosave posts are not directly editable, this results in an error message if the user proceeds to reload the page.
Implementation notes:
As part of some consolidation refactoring in #6257, I made assumptions about an autosave success result receiving a post object, which is only partly correct. In fact, the autosave endpoints return a subset of post properties. Notably, this does not include some properties like
status
, which is considered in both the effects handlers for post save success and failure, and would beundefined
in the case of an autosave. Since these handlers seem to handle this gracefully, I did not address that as part of the changes here, but it seems fragile to allow this assumption to continue.This change was intended to be the minimal fix to allow a 3.0 release to proceed, but I'd like to proceed with future refactorings of this behavior in subsequent pull requests, both:
editor
toedit-post
RESET_POST
, which won't trigger on autosave, only full saves.Testing instructions:
Repeat steps to reproduce from #7066, verifying that no error screen is presented, and that the browser URL does not change after an autosave occurs for a published post.
Ensure unit tests pass: