AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
835 stars 171 forks source link

Block editor is automatically updating existing posts #374

Open blogtutor opened 4 years ago

blogtutor commented 4 years ago

When editing an existing blog post with the block editor, once each minute the block editor will update the post (taking changes live -- as if clicking the "Update" button), rather than just auto-saving a revision.

We've narrowed it down to ACF 5.9.0 (both free and pro). We first encountered this on a client site, and then on a second live site. I've recreated the problem on a development site running WP 5.5, Twenty Twenty, and with ACF as the only active plugin.

The live sites were running 5.4.2, so this isn't just a 5.5 issue.

Step to duplicate:

  1. Edit a published post in the block editor.
  2. Make some changes to the content.
  3. Wait ~60 seconds with the editor open.
  4. When admin-ajax.php triggers, it will also update the post and the changes will go live.

If you watch the request in the Devtools Network tab, you'll see admin-ajax.php appear, and at the same time a second URL to https://domain.com/wp-json/wp/v2/posts/1234?_locale=user.

If no changes are made after that and you just let the editor sit there, admin-ajax.php will keep triggering every minute, but it won't update again. If you then make some more changes, on the next heartbeat it'll update again.

elliotcondon commented 4 years ago

Hi @blogtutor 👋. Thanks for the bug report, sorry for the issue.

Can you please try the fix mentioned in this ticket: https://github.com/AdvancedCustomFields/acf/issues/373

Very interested to hear if this solves the issue.

blogtutor commented 4 years ago

Good morning @elliotcondon! I just swapped in those two .js files on my test site (per #373 ), and that did indeed solve it! 🎉😁

yiudev commented 4 years ago

Hi @elliotcondon , I have the same issue as @blogtutor . I tried to implement the fix (swapping the two JS files) but it didn't work out.

WordPress version: 5.5.1 ACF plugin version: 5.9.0

blogtutor commented 4 years ago

@yiudev Did you clear all caches? If your site uses a CDN, or any kind of server-side static file cache (like Varnish), you'll need to flush that - and also make sure to clear your browser's cache.

yiudev commented 4 years ago

@blogtutor , Yes, I did everything you've mentioned but still didn't work. I did even tried accessing my site through incognito to make sure no cache is available.

I'm using cloudflare as a CDN, I did purge all cache there a couple of times but same issue.

blogtutor commented 4 years ago

Huh. Swapped out those two .js files definitely solved the auto-saving issue for me - on several sites. 🤷‍♂️ Will have to defer to @elliotcondon on this!

yiudev commented 4 years ago

@blogtutor Yeah, thanks for the reply. By the way, I'll just attached a screenshot here of the errors I have encountered. Thanks again.

error

elliotcondon commented 4 years ago

@yiudev Thanks for the feedback. I've just updated the hotfix files. Can you please test out the latest code?

yiudev commented 4 years ago

Hi @elliotcondon , okay, I will test it now and will let you know. Thank you so much.

yiudev commented 4 years ago

Hi @elliotcondon , I just implemented your fix for the JS files (acf-input.js & acf-input.min.js), purged my cache in Cloudflare, and cleared my browser cache as well BUT the issue and errors are still there.

Below is how the errors are displayed:

  1. Clicked on a page to edit, inserted/edited a text in the "Wysiwyg Editor" (acf field) just to have an update then clicked save draft.

errors

elliotcondon commented 4 years ago

@yiudev If it's not too much to ask, can you please spin up a fresh WP site in "Local by Flywheel" and try to replicate the issue? Please keep the default theme active and edit the functions.php file with any extra logic needed.​

​​If you can replicate the issue, please export the site (from flywheel app, right click the site and click "export") and attach to your next reply. ​I'll import this and get to work replicating / testing the issue :)

yiudev commented 4 years ago

@elliotcondon , thank you for your reply. I tried to replicate the issue in "Local by Flywheel" but it works fine. I'm not sure now where this issue came from (hosting or cloudflare). Thanks for your help.

yiudev commented 4 years ago

Hi @elliotcondon , I also noticed that when adding content to the Wysiwyg Editor or Text Area (ACF field) with an HTML code, the error occurs. It does not work just like before where I can add HTML or an inline styles without any problem. Thanks.

elliotcondon commented 4 years ago

@yiudev Can you please create a new ticket with a full description to replicate this issue? A screen recording would be extremely useful too.

yiudev commented 4 years ago

@elliotcondon , I have now fixed my issue. All along, it wasn't the ACF but instead on my SSL certificate. Thank you for your help.