Support

Account

Home Forums Bug Reports WordPress 3.6 Revisions: custom fields no longer tracked

Solved

WordPress 3.6 Revisions: custom fields no longer tracked

  • In WordPress 3.6, changes to custom fields are no longer tracked in Revisions. Tracking custom field revisions in 3.5 seemed to be a feature that ACF added to WordPress. It’s no longer working in 3.6.

  • Hi @eablokker

    Thanks for the bug report.
    Can you please change this topic to a quest so it can be marked as solved when fixed?

  • Hi @eablokker

    After some simple testing, I can confirm that the custom field values are indeed saving to the revisions correctly and even work in the beautiful 3.6 interface.

    Is it possible that your post type does not support revisions? Perhaps there is a conflict in the save_post action which is preventing ACF from saving to the revision?

  • Actually what I’m seeing is that custom field values are being tracked, but only when comparing the most recent revision to the next previous revision. If I go back in time further, that’s when I don’t see any revision comparisons for custom fields.

    I am using a custom post type… but I’m sure it does support revisions because everything worked fine in WordPress 3.5, and I do see all revisions for the title field. A revision point only gets saved when I make a change to the title. Otherwise if I just change a custom field, a revision point is not saved.

  • Hi @eablokker

    Thanks for the clarification.

    I’ll do some testing and get back to you

  • I’ve also noticed that the revisions appear to work for pages/posts you’ve already created, but if you create a new page under WP 3.6 and add some ACF custom fields then none of it shows up in the revisions interface.

  • Hey guys.

    This has now been fixed. You can find the fix included in the latest code on github.

    A 4.2.1 version will be out shortly with this fix.

    Thanks
    E

  • Awesome, thanks! I was waiting for this to get fixed before upgrading all my sites to 3.6.

  • Just to confirm, a post revision point will not be created unless an edit is made to the actual default post content, right? I can see the updated custom fields fine in the revisions interface but new revision points aren’t saved unless a change has been made to the standard post content.

  • @hereswhatidid Oh yeah you’re right. This is still an issue in ACF 4.2.1. Revision point is still not created if you change only a custom field.

  • Having the same issue as @hereswhatidid and @eablokker. Revisions are only created when the title or content are changed. After a bit of digging, looks like will be needing a hook on to wp_save_post_revision_check_for_changes.

    PS. Thank you Elliot. Your plugin is godly and what I’ve needed for years.

  • Hi @acmoore

    Thanks for the code, I’ll take a look and add it to the core!

    Cheers
    E

  • I’m also having the problem with custom fields not being saved to revisions when the post content is not changed. As soon as I modify the main post content, the changes to the custom fields are also saved.

    WP 3.6 & ACF 4.2.2.

  • FYI, it looks like this might make it into WP Core at some point, but who knows how long that will take…
    http://core.trac.wordpress.org/ticket/20564

  • Hi @Dalton

    Thanks for the link, very interesting.

    I’ll take a look at comparing the meta_date and creating a revision, however, I don’t know how far the rabbit hole goes with this one.

    Will ACF start creating un wanted revisions when editing ‘other’ kinds of meta data, etc?

    Thanks
    E

  • Hi all – I’m seeing the same issues as Dalton. I’ve (unfortunately) got a site that’s waiting to launch because the client would like revisions to work on all fields. Are there any temporary hacks / patches I can drop in to get this working now? Seems to work fine if the title or post content is changed.

    Any help would be much appreciated. Thanks!

  • This is really interesting: https://uproot.us/addons/revisions/

    I believe Custom Field Suite is a fork of an older version of ACF, so it may be possible to port this add-on over to ACF.

  • In my add on, date and time picker field, date and time is stored as a timestamp.

    When a user open a post to edit the date and time field, I use format_value() to convert the timestamp to the format the user set when he created the field.

    What should I use to convert the timestamp to the correct format in revisions ?

    edit: @elliot ?

  • There is a filter that I am using to force the save of a revision.

    apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision, $post ) // from wp-includes/revision.php

  • Hi @charl

    Nice! Thanks for the code mate!

  • Hi guys.

    I have pushed an update to github which includes a solution for saving revisions when only a custom field value is changed.

    To clarify the issue, WP only saves a revision if it sees a change in post_title, post_excerpt or post_content. The new code hooks in and tells WP if a metavalue has changed. If so, allow the revision to be saved!

    Thanks for all your help.

    Cheers
    E

  • Fantastic, I can confirm this is working for me. Hats off to you Elliot.

  • I’m on WordPress 3.6.1 and ACF 4.2.2 and I’m experiencing this issue with a custom post type. The post type is not public, and is set to only support title and revisions. Changes to the title cause new revisions to be created, but changing values of ACF fields do not.

  • Hi @timothy_h

    Please see my previous comment:

    I have pushed an update to github which includes a solution for saving revisions when only a custom field value is changed.

    To clarify the issue, WP only saves a revision if it sees a change in post_title, post_excerpt or post_content. The new code hooks in and tells WP if a metavalue has changed. If so, allow the revision to be saved!

    Cheers
    E

  • Hi Elliot,

    Can you please advise how I can include the fix for this without having to update to the latest version, I can see 2 files in Guthub https://github.com/elliotcondon/acf/tree/master/core/controllers revision.php and posts.php which I think has the fix but I do not know how to implement.

    Thanks in advance,
    Will

Viewing 25 posts - 1 through 25 (of 38 total)

The topic ‘WordPress 3.6 Revisions: custom fields no longer tracked’ is closed to new replies.