Make WordPress Core

Changeset 23872


Ignore:
Timestamp:
03/29/2013 08:50:09 PM (12 years ago)
Author:
markjaquith
Message:

Make sure the first revision is seen as coming from emptiness, so it can be restored.

props adamsilverstein. fixes #23898.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r23832 r23872  
    21312131        $right_revision = get_post( $single_revision_id );
    21322132
     2133    if ( 0 == $compare_to )
     2134            $left_revision = get_post( $post_id );
     2135
    21332136    // make sure the right revision is the most recent
    21342137    if ( $compare_two_mode && $right_revision->ID < $left_revision->ID ) {
     
    21562159                 $args = array( 'show_split_view' => true );
    21572160
    2158             $diff = wp_text_diff_with_count( $left_content, $right_content, $args );
     2161            // compare_to == 0 means first revision, so compare to a blank field to show whats changed
     2162            $diff = wp_text_diff_with_count( ( 0 == $compare_to) ? '' : $left_content, $right_content, $args );
    21592163
    21602164            if ( isset( $diff[ 'html' ] ) )
     
    21862190
    21872191    $previous_revision_id = 0;
     2192
    21882193    foreach ( $revisions as $revision ) :
    21892194        //error_log( ( $show_autosaves  ));
     
    22702275            $revision_date_author = $tmp;
    22712276        }
    2272         if ( ( $compare_two_mode || 0 !== $previous_revision_id ) ) {
     2277        if ( ( $compare_two_mode || -1 !== $previous_revision_id ) ) {
    22732278            $alltherevisions[] = array (
    22742279                'ID' => $revision->ID,
  • trunk/wp-admin/js/revisions.js

    r23831 r23872  
    425425            render: function() {
    426426                var addHtml = '';
     427                var thediff;
    427428                // compare two revisions mode?
    428429
    429430                if ( 2 === REVAPP._compareOneOrTwo ) {
     431
    430432                    this.comparetwochecked = 'checked';
    431433                    if ( this.draggingLeft ) {
    432                             if ( this.model.at( REVAPP._leftDiff ) ) {
     434                        thediff = REVAPP._leftDiff -1;
     435                        if ( this.model.at( thediff ) ) {
    433436                            addHtml = this.template( _.extend(
    434                                 this.model.at( REVAPP._leftDiff ).toJSON(),
     437                                this.model.at( thediff ).toJSON(),
    435438                                { comparetwochecked: this.comparetwochecked } // keep the checkmark checked
    436439                            ) );
    437440                        }
    438441                    } else { // dragging right handle
    439                         var thediff = REVAPP._rightDiff;
     442                        thediff = REVAPP._rightDiff -1;
    440443                        if ( this.model.at( thediff ) ) {
    441444                            addHtml = this.template( _.extend(
  • trunk/wp-includes/post-template.php

    r23849 r23872  
    14271427    $parent_included = _wp_last_revision_matches_current_post( $post_id );
    14281428    if ( $parent_included && ! $parent )
    1429         array_pop( $revisions );
     1429        array_shift( $revisions );
    14301430    elseif ( ! $parent_included && $parent )
    14311431        array_unshift( $revisions, $post );
     
    14371437        if ( !current_user_can( 'read_post', $revision->ID ) )
    14381438            continue;
    1439        
     1439
    14401440        $is_autosave = wp_is_post_autosave( $revision );
    14411441        if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) )
Note: See TracChangeset for help on using the changeset viewer.