Skip to content

Commit

Permalink
Revisions: remove the new _wp_last_revision_matches_current_post(), c…
Browse files Browse the repository at this point in the history
…an be replaced by a simple revisions version check. Fixes #23913

git-svn-id: http://core.svn.wordpress.org/trunk@23885 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
azaozz committed Apr 2, 2013
1 parent 6806d48 commit 51826e4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
2 changes: 1 addition & 1 deletion wp-includes/post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {

// Since 3.6 revisions include a copy of the current post data as a revision.
// The following removes that revision when $parent == false
$parent_included = _wp_last_revision_matches_current_post( $post_id );
$parent_included = _wp_get_post_revision_version( reset( $revisions ) ) > 0;
if ( $parent_included && ! $parent )
array_shift( $revisions );
elseif ( ! $parent_included && $parent )
Expand Down
43 changes: 0 additions & 43 deletions wp-includes/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,49 +657,6 @@ function _wp_upgrade_revisions_of_post( $post ) {
return true;
}

/**
* Determines if the specified post's most recent revision matches the post (by checking post_modified).
*
* @package WordPress
* @subpackage Post_Revisions
* @since 3.6.0
*
* @param int|object $post Post ID or post object.
* @return bool false if not a match, otherwise true.
*/
function _wp_last_revision_matches_current_post( $post ) {
if ( ! $post = get_post( $post ) )
return false;

if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
return false;

foreach ( $revisions as $revision ) {
if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
$last_revision = $revision;
break;
}
}

// No revisions yet, only autosaves
if ( ! isset( $last_revision ) )
return false;

$post_has_changed = false;
if ( $last_revision->post_modified == $post->post_modified ) {
foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) {
$post_has_changed = true;
break;
}
}
} else {
return false;
}

return ! $post_has_changed;
}

/**
* Displays a human readable HTML representation of the difference between two strings.
* similar to wp_text_diff, but tracks and returns could of lines added and removed
Expand Down

0 comments on commit 51826e4

Please sign in to comment.