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

Cannot redeclare get_post_type_graphql_fields() previously declared #161

Closed
renatonascalves opened this issue Jun 28, 2023 · 0 comments · Fixed by #162
Closed

Cannot redeclare get_post_type_graphql_fields() previously declared #161

renatonascalves opened this issue Jun 28, 2023 · 0 comments · Fixed by #162

Comments

@renatonascalves
Copy link
Contributor

renatonascalves commented Jun 28, 2023

I noticed this bug while adding unit tests in a plugin.

PHP Fatal error:  Cannot redeclare get_post_type_graphql_fields() (previously declared in /var/www/project/wp-content/plugins/add-wpgraphql-seo/wp-graphql-yoast-seo.php:748) in /var/www/project/wp-content/plugins/add-wpgraphql-seo/wp-graphql-yoast-seo.php on line 748

Fatal error: Cannot redeclare get_post_type_graphql_fields() (previously declared in /var/www/project/wp-content/plugins/add-wpgraphql-seo/wp-graphql-yoast-seo.php:748) in /var/www/project/wp-content/plugins/add-wpgraphql-seo/wp-graphql-yoast-seo.php on line 748

The issue seems to be because this function is being instantiated inside the graphql_register_types hook action which can be run multiple times.

function get_post_type_graphql_fields($post, array $args, AppContext $context)

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 a pull request may close this issue.

1 participant