corcel / acf

Advanced Custom Fields (ACF) plugin for Corcel
127 stars 100 forks source link

Fix for getFieldType sometimes returning the wrong post #26

Closed njbarrett closed 7 years ago

njbarrett commented 7 years ago

Fix for getFieldType sometimes returning the wrong post, e.g not an ACF field.

I was debugging for a while, trying to work out why my Repeater Fields were coming back as Text. It seemed that the query in fetchFieldType was returning the wrong post. I am not sure why it was built to use ->orWhere() as it seems like you are not guaranteed to get the post with post_name = $fieldKey and post_type = 'acf-field'. Shouldn't this query explicitly look for one row matching those parameters?

In my case, it resolved the issue I was experiencing.