Make WordPress Core

Changeset 23885


Ignore:
Timestamp:
04/02/2013 07:39:48 PM (11 years ago)
Author:
azaozz
Message:

Revisions: remove the new _wp_last_revision_matches_current_post(), can be replaced by a simple revisions version check. Fixes #23913

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r23872 r23885  
    14251425    // Since 3.6 revisions include a copy of the current post data as a revision.
    14261426    // The following removes that revision when $parent == false
    1427     $parent_included = _wp_last_revision_matches_current_post( $post_id );
     1427    $parent_included = _wp_get_post_revision_version( reset( $revisions ) ) > 0;
    14281428    if ( $parent_included && ! $parent )
    14291429        array_shift( $revisions );
  • trunk/wp-includes/revision.php

    r23867 r23885  
    659659
    660660/**
    661  * Determines if the specified post's most recent revision matches the post (by checking post_modified).
    662  *
    663  * @package WordPress
    664  * @subpackage Post_Revisions
    665  * @since 3.6.0
    666  *
    667  * @param int|object $post Post ID or post object.
    668  * @return bool false if not a match, otherwise true.
    669  */
    670 function _wp_last_revision_matches_current_post( $post ) {
    671     if ( ! $post = get_post( $post ) )
    672         return false;
    673 
    674     if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
    675         return false;
    676 
    677     foreach ( $revisions as $revision ) {
    678         if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
    679             $last_revision = $revision;
    680             break;
    681         }
    682     }
    683 
    684     // No revisions yet, only autosaves
    685     if ( ! isset( $last_revision ) )
    686         return false;
    687 
    688     $post_has_changed = false;
    689     if ( $last_revision->post_modified == $post->post_modified ) {
    690         foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
    691             if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) {
    692                 $post_has_changed = true;
    693                 break;
    694             }
    695         }
    696     } else {
    697         return false;
    698     }
    699 
    700     return ! $post_has_changed;
    701 }
    702 
    703 /**
    704661 * Displays a human readable HTML representation of the difference between two strings.
    705662 * similar to wp_text_diff, but tracks and returns could of lines added and removed
Note: See TracChangeset for help on using the changeset viewer.