ashhitch/wp-graphql-yoast-seo

Cannot redeclare `get_post_type_graphql_fields()` previously declared

renatonascalves opened this issue · 0 comments

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)