Make WordPress Core

Opened 8 years ago

Last modified 8 years ago

#44929 new defect (bug)

Revisions: wp_get_revision_ui_diff only displays existing meta fields of the current post

Reported by: luisarn Owned by:
Priority: normal Milestone: Awaiting Review
Component: Revisions Version:
Severity: normal Keywords:
Cc: Focuses: ui, administration

Description

For reproducing the issue:

  1. Turn on revisions
  2. Create a post
  3. Save
  4. Create a custom field with some value
  5. Save
  6. Delete the custom field
  7. Save
  8. Go to the revision comparison
  9. The field added and deleted won't display in the comparision

After doing some debug I found out that the the foreach loop in the function wp_get_revision_ui_diff in wp-admin\includes\revision.php uses _wp_post_revision_fields( $post ) which only takes into consideration of the custom fields of the actual post.

Solution:

Change:

foreach ( _wp_post_revision_fields( $post ) as $field => $name ) {

To:

$fields_from = array();
$fields_to = array();
if ( $compare_from != null )
	$fields_from = _wp_post_revision_fields( $compare_from );
if ( $compare_to != null )
	$fields_to = _wp_post_revision_fields( $compare_to );
$fields = array_merge( $fields_from, $fields_to, _wp_post_revision_fields( $post ) );

foreach ( $fields as $field => $name ) {

Change History (3)

#1 @mukesh27
8 years ago

  • Component AdministrationRevisions

#3 @pento
8 years ago

  • Version trunk
Note: See TracTickets for help on using tickets.