Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#58739 closed defect (bug) (fixed)

Return original autosave after saving with unchanged data

Reported by: adamsilverstein's profile adamsilverstein Owned by: adamsilverstein's profile adamsilverstein
Milestone: 6.3 Priority: normal
Severity: normal Version: 6.2
Component: Revisions Keywords: has-patch has-unit-tests commit add-to-field-guide
Focuses: Cc:

Description

This is a follow up to https://core.trac.wordpress.org/ticket/49532. In https://core.trac.wordpress.org/changeset/55154 the autosave endpoint was adjusted so that if the autosave was a duplicate (no data had changed) an error was returned. This fixed an issue where the autosave would be deleted and recreated each time the (unchanged) data was saved.

Unfortunately, this caused at least two regressions as noted in https://core.trac.wordpress.org/ticket/49532#comment:33 and https://github.com/WordPress/gutenberg/issues/51088.

After reviewing this more carefully, a better approach would be to return the original autosave instead of an error - that way, endpoint consumers will get the data back in the shape the expect and the autosave will work as expected.

Patch incoming

Attachments (1)

58739.diff (2.9 KB) - added by adamsilverstein 15 months ago.

Download all attachments as: .zip

Change History (10)

#1 @adamsilverstein
15 months ago

  • Owner set to adamsilverstein
  • Status changed from new to assigned

This ticket was mentioned in PR #4807 on WordPress/wordpress-develop by @adamsilverstein.


15 months ago
#2

  • Keywords has-patch has-unit-tests added; needs-patch removed

#3 @Mamaduka
15 months ago

Thank you, Adam!

I re-tested the patch, and it works as expected.

There's no longer a 400 error when previewing an already published post, and thumbnail changes are reflected in the previews.

#4 @adamsilverstein
15 months ago

  • Keywords commit added

#5 @adamsilverstein
15 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56163:

Revisions: return existing autosave after saving with unchanged data.

Correctly return the existing autosave when an unchanged autosave is saved, instead of returning an error.

Fix regressions after r55154 where an error and not the original autosave was returned when saving with unchanged data (for example, clicking the preview button repeatedly). Returning the autosave (ID) is the expected behavior for the endpoint.

Follow up to [55154]

Props Mamaduka, jeroenrotty, mrfoxtalbot.
Fixes #58739.

#6 @spacedmonkey
15 months ago

@adamsilverstein This is a change in behaviour for the REST API. As this is a change, it needs to be either called out in the field guide or have a dev note.

#7 @adamsilverstein
15 months ago

  • Keywords needs-dev-note added

#8 @adamsilverstein
15 months ago

  • Keywords add-to-field-guide added; needs-dev-note removed

#9 @adamsilverstein
15 months ago

Thinking more appropriate for field guide since it is a relatively small change/note and more than likely fixes a bug for developers rather than needing them to make some change in their code. Before 6.2 the endpoint always returned an autosave and this restores that behavior, so probably what developers already expect from the endpoint.

Note: See TracTickets for help on using tickets.