diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
index 0a2cf5d49b..5adb947c9f 100644
|
|
|
class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { |
| 362 | 362 | $new_autosave['ID'] = $old_autosave->ID; |
| 363 | 363 | $new_autosave['post_author'] = $user_id; |
| 364 | 364 | |
| 365 | | // If the new autosave has the same content as the post, delete the autosave. |
| 366 | | $autosave_is_different = false; |
| 367 | | |
| 368 | | foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { |
| 369 | | if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) { |
| 370 | | $autosave_is_different = true; |
| 371 | | break; |
| 372 | | } |
| 373 | | } |
| 374 | | |
| 375 | | if ( ! $autosave_is_different ) { |
| 376 | | wp_delete_post_revision( $old_autosave->ID ); |
| 377 | | return new WP_Error( |
| 378 | | 'rest_autosave_no_changes', |
| 379 | | __( 'There is nothing to save. The autosave and the post content are the same.' ), |
| 380 | | array( 'status' => 400 ) |
| 381 | | ); |
| 382 | | } |
| 383 | | |
| 384 | 365 | /** This filter is documented in wp-admin/post.php */ |
| 385 | 366 | do_action( 'wp_creating_autosave', $new_autosave ); |
| 386 | 367 | |