[wp-trac] [WordPress Trac] #44929: Revisions: wp_get_revision_ui_diff only displays existing meta fields of the current post
WordPress Trac
noreply at wordpress.org
Tue Sep 11 08:38:42 UTC 2018
#44929: Revisions: wp_get_revision_ui_diff only displays existing meta fields of
the current post
--------------------------------+-----------------------------
Reporter: luisarn | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: trunk
Severity: normal | Keywords:
Focuses: ui, administration |
--------------------------------+-----------------------------
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 ) {
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44929>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list