[wp-trac] [WordPress Trac] #49532: Clicking "preview" multiple times on a post causes an identical autosave revision to be created and destroyed repeatedly
WordPress Trac
noreply at wordpress.org
Tue Jan 17 21:46:06 UTC 2023
#49532: Clicking "preview" multiple times on a post causes an identical autosave
revision to be created and destroyed repeatedly
-------------------------------------------------+-------------------------
Reporter: inwerpsel | Owner:
| adamsilverstein
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.2
Component: Revisions | Version: 5.4
Severity: normal | Resolution:
Keywords: has-patch needs-testing dev- | Focuses: rest-api,
feedback early has-unit-tests | performance
-------------------------------------------------+-------------------------
Changes (by ironprogrammer):
* keywords:
has-patch reporter-feedback needs-testing dev-feedback early has-unit-
tests
=> has-patch needs-testing dev-feedback early has-unit-tests
Comment:
Thanks for the latest updates to this, @adamsilverstein and @mukesh27! The
steps below were adapted to include confirmation of autosave revision
record changes.
== Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3794
👍🏻
=== Steps to Reproduce or Test
1. Create a new post.
2. Enter a post title, press Return or move the cursor to the block
inserter, and publish the post. **Make note of the post's ID.**
3. Do not make any changes to the post. Click ''Preview > Preview in new
tab''.
4. 🐞 Observe that:
- In browser dev tools that the request to `/wp-
json/wp/v2/posts/{id}/autosaves?_locale=user` resulted in an HTTP 200
(okay) response. The response body contains details about the new autosave
revision. **Make note of the autosave's post ID.**
- In the database an autosave revision record was created for the post
(where `post_parent` matches the post's ID, and the `post_name` is
formatted as "{post_parent}-autosave-v1").
5. Repeat Step 3.
6. 🐞 Observe that:
- In dev tools the new request to `/wp-
json/wp/v2/posts/{id}/autosaves?_locale=user` resulted in an HTTP 400
(error) response. The response body contains the code
`rest_autosave_no_changes`.
- In the database the autosave revision record was **deleted**.
7. Repeat Step 3.
10. 🐞 Observe that:
- In dev tools the new request to `/wp-
json/wp/v2/posts/{id}/autosaves?_locale=user` resulted in an HTTP 200
(okay) response, with details about a new autosave revision. **Note that
the autosave's post ID is new.**
- In the database a **new** autosave revision record was created for the
post.
=== Expected Results
When reproducing the bug:
- ❌ When there have been no changes to the post, previewing the post
causes a new autosave to be created.
- ❌ If an autosave existed, previewing the post causes the autosave to be
deleted.
- ❌ Subsequent previews continue to create new and then delete autosave
records when no changes have been made.
When testing a patch:
- ✅ When there have been no changes to the post, previewing the post
should not create a new autosave.
- ✅ If the post is changed, previewing should create an autosave, or
update the existing autosave if it exists.
- ✅ Subsequent previews should not create a new autosave when no changes
have been made.
=== Environment
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 12.6.2
- Browser: Safari 16.2
- Server: nginx/1.23.3
- PHP: 7.4.33
- WordPress: 6.2-alpha-54642-src
=== Actual Results
When reproducing the bug:
- ❌ Before patching, testing matched the Expected Results above. 👍🏻
When testing a patch:
- ✅ After patching, previewing the unedited post did not create an
autosave.
- ✅ When the post was modified, previewing the post created an autosave,
or updated the existing autosave record.
- ✅ Clicking preview multiple times did not alternate between creating
and deleting new autosave records in the database.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49532#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list