Skip to content
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

Guard against false terms when plucking IDs #364

Merged
merged 5 commits into from
Nov 10, 2020

Conversation

jacobarriola
Copy link
Contributor

get_the_terms can return false, which causes errors when running anything other than an array in wp_list_pluck. Related to #363.

What does this implement/fix? Explain your changes.

Fixes an ErrorException Invalid argument supplied for foreach() when we pass anything other than an array to wp_list_pluck() when connecting a term to a product.

Does this close any currently open issues?

#363

Any relevant logs, error output, GraphiQL screenshots, etc?

See the issue.

jacobarriola and others added 3 commits November 9, 2020 14:10
`get_the_terms` can return `false`, which causes errors when running anything other than an array in `wp_list_pluck`. Related to wp-graphql#363.
Copy link
Member

@kidunot89 kidunot89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobarriola Great work on this. I'm sorry it took so long for me to really look at this problem.

includes/connection/class-wc-terms.php Outdated Show resolved Hide resolved
Co-authored-by: Geoffrey K Taylor <geoffrey.taylor@outlook.com>
$resolver = new TermObjectConnectionResolver( $source, $args, $context, $info, $tax_object->name );


$term_ids = \wc_get_object_terms( $object_id, $taxonomy, 'term_id' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad 😅, it should be $tax_object->name not $taxonomy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 yup, I saw that after too. It's corrected now.

@kidunot89 kidunot89 merged commit 5230e69 into wp-graphql:develop Nov 10, 2020
@jacobarriola jacobarriola deleted the patch-3 branch November 10, 2020 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants