After an upgrade I see duplicate fields in some of our field groups. I’ve tracked it down to there being duplicate fields before the upgrade that don’t show up in the ACF UI.
For example, before upgrading I can see this in the db for one of the duplicated fields.
+———+———+———————+
| meta_id | post_id | meta_key |
+———+———+———————+
| 5440 | 4 | field_53cd8928a638a |
| 8218 | 4 | field_53cd8928a638a |
| 9108 | 4 | field_53cd8928a638a |
| 26411 | 4 | field_53cd8928a638a |
| 26432 | 4 | field_53cd8928a638a |
| 26453 | 4 | field_53cd8928a638a |
| 36255 | 4 | field_53cd8928a638a |
| 36276 | 4 | field_53cd8928a638a |
| 36297 | 4 | field_53cd8928a638a |
+———+———+———————+
I suspect this happened when we were importing the field groups between systems. If the existing posts aren’t deleted before importing, duplicate meta data can be created.
I think ACF v4 handled this, while v5 is exposing it.
I was able to fix it by changing the query in advanced-custom-fields-pro/admin/updates/5.0.0.php
// get field from postmeta
$rows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key LIKE %s", $ofg->ID, 'field_%'), ARRAY_A);
change the “SELECT *” to “SELECT DISTINCT post_id,meta_key,meta_value”
Thanks a bunch for sharing this!
I have alerted Elliot about this, it should be rectified soon.
I had this exact problems, I had a backup ready, but its still a mess to sort out. Why have not this problem been adressed since september?
Best regards Andreas
Hello guys,
First of all thank you very much for such an amazing plugin.
I have a pretty large website that we need updating to v5.
Have just performed the update in one of my “dummy” stage copies of the site and some field groups end up with crazy duplicates (some fields duplicated up to 5-6 times).
Same issue as the guys above I believe.
Is there any way to avoid this at all?
We need to perform the update as v5 has many features we would love to make use of however we can’t really afford to be cleaning up data dups etc..
Thank you for your attention
Thanks guys.
I’ve added this to my to-do and will have it fixed in the next major version!
Hi guys
Sorry for the delay on this issue. I’ve just fixed it and will include in the next version – 5.5.0
The topic ‘Duplicate Fields after v5 Upgrade’ is closed to new replies.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.