What is the priority of your acf/save_post action?
Also, I can’t be sure without seeing your action filter. The DB query to delete should be done before ACF inserts new data, so I can’t see why the deletion would continue while the update is being done.
Also, you may need to clear the meta cache for the post after you do the query. Here is what happens when a field is updated, what WP does.
First it does a query to see if the value is already in the DB. However, if the value is the the cache then it does not to the query and instead uses the value from the cache. If the new value and the old value are different then it does an update query, but if they are the same it may or may not do the update query (I have never been able to sort out why it sometimes does the update and other times does not).
There may also be a case where all of the data will be deleted but nothing new will be saved. This could happen if you update a post without making any changes to ACF fields. There is a hidden field for ACF that is a flag indicating if anything was updated. If this flag is not set then ACF will not update values but and your acf/save_post action might not be called.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
📣 “ACF Chat Fridays”— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.