WordPress.org

Make WordPress Core

Ticket #24958: 24958.2.diff

File 24958.2.diff, 1.3 KB (added by adamsilverstein, 5 years ago)
  • src/wp-includes/revision.php

     
    9898
    9999        // Compare the proposed update with the last stored revision verifying that
    100100        // they are different, unless a plugin tells us to always save regardless.
    101         // If no previous revisions, save one
    102         if ( $revisions = wp_get_post_revisions( $post_id ) ) {
     101        // Search back at most 100 revisions to find a non-autosave revision.
     102        // If no previous revisions, save one.
     103        if ( $revisions = wp_get_post_revisions( $post_id, array( 'posts_per_page' => 100 ) ) ) {
    103104                // grab the last revision, but not an autosave
    104105                foreach ( $revisions as $revision ) {
    105106                        if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
     
    196197 * @return object|bool The autosaved data or false on failure or when no autosave exists.
    197198 */
    198199function wp_get_post_autosave( $post_id, $user_id = 0 ) {
    199         $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) );
     200        $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false, 'posts_per_page' => 100 ) );
    200201
    201202        foreach ( $revisions as $revision ) {
    202203                if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) {