Opened 6 years ago
Last modified 6 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: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Revisions | Keywords: | |
Focuses: | ui, administration | Cc: |
Description
For reproducing the issue:
- Turn on revisions
- Create a post
- Save
- Create a custom field with some value
- Save
- Delete the custom field
- Save
- Go to the revision comparison
- 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)
Note: See
TracTickets for help on using
tickets.
Related: #20564, #20299.