Open tripflex opened 3 months ago
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.
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!
I am also experiencing an issue similar to the above where if I add some text and let it autosave (without modifying any ACF fields), when I go to revisions and view the autosave, ALL ACF fields get removed.
Paragraph added for autosave test:
Autosave Response result:
Revision of the autosave, showing the removed ACF fields:
Is there ANY fix for this please as our content writers are constantly re-writing & re-adding ACF content whenever the post autosaves.
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!
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:
![image](https://github.com/AdvancedCustomFields/acf/assets/553732/6e0a760f-1d46-4ce6-b5ad-9c7f9aa737f5)
Now change the field value:![image](https://github.com/AdvancedCustomFields/acf/assets/553732/1c6a8e28-e2a9-4548-84b3-73395754f6fb)
Click preview in new tab:![image](https://github.com/AdvancedCustomFields/acf/assets/553732/ab5a25ba-93e5-47b2-ad90-e4e7c7174b56)
Nothing shows:![image](https://github.com/AdvancedCustomFields/acf/assets/553732/f44477d0-762b-4cda-8a7d-3bab92eaa8e9)
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: https://github.com/AdvancedCustomFields/acf/issues/411 https://github.com/AdvancedCustomFields/acf/issues/186 https://github.com/AdvancedCustomFields/acf/issues/184
Gutenburg related issue: https://github.com/WordPress/gutenberg/issues/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.