wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
633 stars 123 forks source link

`declare_compatibility()` not compatible with composer #864

Open sbolinger-godaddy opened 1 month ago

sbolinger-godaddy commented 1 month ago

Describe the bug

When the plugin is installed via composer, this HPOS compatibility function throws errors in WooCommerce.

FeaturesUtil::declare_compatibility: /wp-content/plugins/enhanced-checkout-woocommerce/vendor/wp-graphql/wp-graphql-woocommerce/wp-graphql-woocommerce.php is not a known WordPress plugin.

That second parameter: FILE typically corresponds to a path like wp-content/plugins/wp-graphql-woocommerce/wpgraphql-woocommerce.php -- as in, a path for a normal WordPress plugin.

But when it's installed as a composer dependency, it's actually going to be: wp-content/plugins/enhanced-checkout-woocommerce/vendor/wp-graphql/wp-graphql-woocommerce/wpgraphql-woocommerce.php (inside /vendor/ and nested quite deep!)

The problem is that inside that WooCommerce function that they're using (FeaturesUtil::declare_compatibility()) WooCommerce validates that the provided file path is inside the list of currently active plugins that WordPress recognizes (everything ONLY inside wp-content/plugins one layer deep).

In this case, WpGraphQL doesn't meet that criteria. That's when WooCommerce automatically logs the error.

Proposed Solution

Remove this compatibility function. When installed via composer, this should be the job of the parent plugin.

To Reproduce

Steps to reproduce the behavior:

  1. Bundle this plugin via composer into another plugin
  2. Install and activate WooCommerce and your plugin
  3. Visit WooCommerce logs to see the errors

Thanks!

kidunot89 commented 3 weeks ago

@sbolinger-godaddy Implementing the solution shouldn't be too much of an issue. I've added this into the next release's milestone and it should be resolved in the next release. Sorry about any inconveniences this may have caused.

sbolinger-godaddy commented 2 weeks ago

@kidunot89 Thanks so much Geoff!