Make WordPress Core

Ticket #21858: miqro-21858-autosave.2.patch

File miqro-21858-autosave.2.patch, 1.6 KB (added by miqrogroove, 12 years ago)

Finished patch after clarifying the errant code will be fixed in PHP rather than moving it to JS.

  • wp-admin/includes/ajax-actions.php

     
    10881088        if ( $do_autosave ) {
    10891089                // Drafts and auto-drafts are just overwritten by autosave
    10901090                if ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) {
    1091                         $id = edit_post();
     1091
     1092                        // Autosave shouldn't save too soon after a real save
     1093                        $now = time();
     1094                        $then = strtotime($post->post_modified_gmt . ' +0000');
     1095                        $delta = AUTOSAVE_INTERVAL / 2;
     1096
     1097                        if ( abs($now - $then) < $delta )
     1098                                $id = 0; // This tells us it didn't actually save
     1099                        else
     1100                                $id = edit_post(); // Save the post now
     1101
    10921102                } else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
    10931103                        $revision_id = wp_create_post_autosave( $post->ID );
    10941104                        if ( is_wp_error($revision_id) )
  • wp-admin/includes/post.php

     
    158158                        wp_die( __('You are not allowed to edit this post.' ));
    159159        }
    160160
    161         // Autosave shouldn't save too soon after a real save
    162         if ( 'autosave' == $post_data['action'] ) {
    163                 $post = get_post( $post_ID );
    164                 $now = time();
    165                 $then = strtotime($post->post_date_gmt . ' +0000');
    166                 $delta = AUTOSAVE_INTERVAL / 2;
    167                 if ( ($now - $then) < $delta )
    168                         return $post_ID;
    169         }
    170 
    171161        $post_data = _wp_translate_postdata( true, $post_data );
    172162        if ( is_wp_error($post_data) )
    173163                wp_die( $post_data->get_error_message() );