-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ACF post preview and revisions completely broken #903
Comments
Hey there, We're aware of this issue, and there are a few long standing issues in this repo for it. We have a plan to resolve this issue, but it requires us to remove the legacy meta box and transition to a whole new system for updating ACF fields in the block editor, this is a long term project for us. We'll keep you updated on our progress over the next several releases of ACF. |
What can I do to help? I'm happy to do some development work if you can point me in the right direction. Thanks! |
@ConnorWedia Just to clarify, is this a recent change with an ACF or WordPress update, or has this always been the case for you in the block editor? |
@lgladdy The issue has only been happening for a couple of weeks now, and we have since updated Wordpress to 6.5 (thinking it was related), PHP to 8.3, and obviously latest version of ACF. |
Thanks @ConnorWedia - I'll raise it with the team here today and see the updates we made to fix (some) revisions made it worse for autosaves. I will also note, we're prioritising a more immediate fix to this issue now given how recent WordPress updates have made things much worse for revisions and autosaves with ACF metadata. |
@lgladdy is there any movement on previews and revisions with ACF Fields? It works for me always after the first time, but the first time I hit preview after changing some ACF flexible fields, it never displays. Super frustrating! |
@ConnorWedia did you find a solution or workaround to the problem of all ACF values being cleared on autosaves? We're experiencing the same problem... |
Adding our voice to this issue. Working with ACF Pro and experiencing these same issues. Starting to become a problem with our content editors. Any roadmap that can be shared around the "immediate fix" you mentioned @lgladdy? |
@cooperfellows We're actively working on a potential long term fix for this at the moment and have a working internal branch, we'll have more to share on which release will contain this shortly once we're confident everything is working correctly. |
@lgladdy any news on this? |
Describe the bug
The internal handling of ACF for revisions and previews seems to be completely broken in numerous ways when using the default WordPress Gutenberg editor. Any field groups created and attached to a post, either do not show at all when attempting to preview, or if using a workaround to remove the filter, they show values from the last "published" post.
TLDR; Preview does not work correctly for ACF fields if using the default WordPress Gutenburg editor
1.) ACF does not handle revisions correctly, and is using the revision ID when you call
get_field
(see end of issue for details), ultimately causing nothing to show because metadata does not exist on the revision post ID.2.) Even with revisions disabled, preview does not work correctly which probably stems from the same issue above, and does not show anything on preview either.
To Reproduce
Steps to reproduce the behavior:
[acf field="some_field_value"]
shortcode to output on the pageExpected behavior
The value updated when editing to show correctly on the preview
Basic setup and functional when published:
Now change the field value:
Click preview in new tab:
Nothing shows:
Version Information:
Additional context
As a WordPress expert and seasoned plugin developer, here's what I found.
The problem exists in
acf_get_valid_post_id
which calls theacf/validate_post_id
filter, which then is filtered inacf_revisions::acf_validate_post_id
who then callsacf_get_post_latest_revision
which returns the revision ID.The problems stems from the fact that ACF does not store meta on the revision, but for some reason, it's specifically changing Post ID's to the revision ID, ultimately causing the function call to
get_field
to callget_metadata
using the revision post ID, but the only meta that will ever exist on it is something like this:[ '_acf_changed' => [ 0 => "1" ] ]
My assumption is this code was meant for the pre-Gutenburg era, as I also found that when WordPress automatically calls the
autosaves
REST endpoint (every 60 seconds or when you click Preview in new tab), ACF does not have any handling in there to pass any values that have been changed, and since they are not one of the default fieldspost_title, post_content, excerpt, etc
nothing gets saved, and as such, ACF is trying to pull the value from the revision (or autosave if revisions disabled) that will never have anything on it, as ACF has specifically set to only allow_acf_changed
as the only valid meta for revisions/autosaves.Basically it seems that preview only works with ACF if you specifically force the site to use the classic editor. I've tested this on a completely blank install and replicated it numerous times.
Numerous previous issues opened regarding this:
#411
#186
#184
Gutenburg related issue:
WordPress/gutenberg#16006
Regarding Gutenburg issue ... it seems they have no plans to support passing meta fields, so this should be something added/handled via ACF as it's been YEARS and still no resolution. Being as though ACF is so widely used, it makes the most sense that this should be resolved in ACF now that Gutenburg is the default editor -- switching to classic editor is just not an option for some.
The text was updated successfully, but these errors were encountered: