-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve cache keys for acf-value-functions.php #403
base: master
Are you sure you want to change the base?
Conversation
- this avoids having groups with the same field names from clashing - in the case where you query via `wp-graphql-acf` and you have multiple field groups with repeaters that resolve to the same field name, then without this patch the first field group will load the field value and store it inside the cache with the wrong sub-field ids. - for more info see wp-graphql/wp-graphql-acf#170
Hi @rburgst Thanks for submitting this PR. It's quite interesting, but suggests that it be possible to register multiple fields with the same name on a single object. In theory, a single post should only be able to contain 1 meta value for "featured_image", not multiple. |
Hi, the problem is explained in wp-graphql/wp-graphql-acf#170. When querying the data via graphql the default location rules do not properly apply. Therefore it is possible that you can query multiple field groups on the same page even if in ACF they do not really apply (however, you can always obviously map 2 field groups to the same page which achieves a similar problem). |
Thanks @rburgst This explanation really helped to better understand the issue. You are right to identify this as a problem within If you change line 63 from I'll need to add this to our dev to-do list, and make sure to run this through A LOT of testing, but am very open to making the change 👍. |
Hi @rburgst Upon further review, I can confirm the suggestion made in my previous comment would prove problematic for sub field values. Please disregard it 🙃. The solution proposed in your PR does appear to be the best way to avoid this issue. In a lot of ways, the addition of the Field's key makes sense, as we are not only loading the Post's meta value (field name), but we are also modifying it based on the field (field key). The combination of field name + field key creates a more specific cache key for that desired instance. I'll need to consider how this cache key change would effect the plugin from a larger point of view, and will mark this tentatively for the 5.10 release. |
@elliotcondon can you provide an ETA? |
Hi @rburgst. No update just yet. Did you ever receive a response from the "wp-graphql" devs on the bug? This issue should be easily avoidable by better checking which fields are mapped to which objects. At the moment, this is a simple process of checking for reference values (which are saved alongside the meta value). |
I fear a wp-graphql-acf fix wont happen any time soon. wp-graphql/wp-graphql-acf#135 |
any news here? |
Important patch for us. Any ETA on this issue so that we no longer need to patch new versions. |
Error still happen on: Can you merge as soon as possible? |
@elliotcondon I checked with wp-graphql 0.5.0 and the problem persists, so this patch is still relevant and needed. |
@elliotcondon |
wp-graphql-acf
andyou have multiple field groups with repeaters that resolve to the
same field name, then without this patch the first field group
will load the field value and store it inside the cache
with the wrong sub-field ids.
Acf fields return null with repeater/group wp-graphql/wp-graphql-acf#170