Make WordPress Core

Ticket #7392: 7392.8.diff

File 7392.8.diff, 1.1 KB (added by nacin, 11 years ago)
  • wp-admin/includes/post.php

     
    13201320                $new_autosave['ID'] = $old_autosave->ID;
    13211321                $new_autosave['post_author'] = $post_author;
    13221322
     1323                // If the new autosave is the same content as the post, delete the old autosave.
     1324                $post = get_post( $post_id );
     1325                $autosave_is_different = false;
     1326                foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
     1327                        if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
     1328                                $autosave_is_different = true;
     1329                                break;
     1330                        }
     1331                }
     1332
     1333                if ( ! $autosave_is_different ) {
     1334                        wp_delete_post_revision( $old_autosave->ID );
     1335                        return;
     1336                }
     1337
    13231338                return wp_update_post( $new_autosave );
    13241339        }
    13251340
    13261341        // _wp_put_post_revision() expects unescaped.
    1327         $_POST = wp_unslash($_POST);
     1342        $post_data = wp_unslash( $_POST );
    13281343
    13291344        // Otherwise create the new autosave as a special post revision
    1330         return _wp_put_post_revision( $_POST, true );
     1345        return _wp_put_post_revision( $post_data, true );
    13311346}
    13321347
    13331348/**