I just encountered a problem that is not 100% related to ACF, but I think it’s worth noticing, and it might even help someone who is in my case.
I created a custom field with the name “description”, so it’s stored in the database as it.
Then I installed the plugin All In One SEO pack, wich immediately told me that I needed to update my DB because it has found old entries. So I did.
When it updated the DB, it had in actually transformed all “description” fields to “aioseop_description”. But actually it was my own custom fields, not its old ones. I first thought that WordPress erased all my descriptions, but when looking in the DB I understood what happened.
So I thought it would be interesting to prefix ACF fields names in the DB to avoid conflicts like this one. It could even be an option for those who don’t need it.
What do you think ?
better would be to create forbidden field name list
Thanks for the feedback. I’m not sure how ACF would be able to test this as I don’t want the plugin to become bloated from 3rd party upgrades.
I can understand the frustration but this is a 1 in a million bug.
Hope it never happens to you again.
@sireneweb How would you be sure to list all custom field names used by other plugins ? Prefixing by “acf_” would ensure by 99,99% that there will never be another conflict I think.
@elliot I didn’t mean that ACF should check other field names or other installed plugins, it would be crazy ! I just meant that a prefixing option would be safer. Because both ACF and All in One SEO Pack are well known and there’re a lot of chances that someone else use those 2 plugins and create a field named “description”… just like me. I’m not sure my case is that rare. I might not be aware of the implications of such a new feature however ?
Why we don’t create a forbidden list for imput field name ?
That would be a huge work and we won’t never be sure to have listed them all. Plus, how would you decide if a name is forbidden or not ? And it would be a shame if we can’t create fields simply named “title”, “description”, or “picture” that are very common names, maybe used by other plugin, now or in the future ?
IMO, the fact that All In One SEO is actually migrating their DB to prefixed field names proves that it’s the good way to do. After all, even WordPress itself prefix its tables names !
Misunderstand me not : I think that ACF should interpret field names itself, in order to not surcharge the templates code uselessly. For example, my code would still be
get_field('description') but it actually would check the
acf_description field in the database, according to the “prefix option” set in the back-office. The transcription would be transparent for developers.
You must be logged in to reply to this topic.
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!
© 2020 Advanced Custom Fields. Subscribe