wp-graphql / wp-graphql-woocommerce

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

php-jwt library conflict with Zapier plugin #775

Closed sbolinger-godaddy closed 1 year ago

sbolinger-godaddy commented 1 year ago

Zapier produces a 500 error when trying to authenticate with WordPress. This is due to a conflict between the php-jwt libraries. The Zapier plugin loads an older version of php-jwt, but it invokes the woographql php-jwt, causing an issue.

The plugin: https://wordpress.org/plugins/zapier/

Here is the error message:

2023-07-26T18:58:58+00:00 CRITICAL Uncaught ArgumentCountError: Too few arguments to function Firebase\JWT\JWT::encode(), 2 passed in /dom24460/wp-content/plugins/zapier/zapier.php on line 127 and at least 3 expected in /dom24460/wp-content/plugins/wp-graphql-woocommerce-2/vendor/firebase/php-jwt/src/JWT.php:184
Stack trace:
#0 /dom24460/wp-content/plugins/zapier/zapier.php(127): Firebase\JWT\JWT::encode(Array, '3cd2db6c16c068c...')
#1 /dom24460/wp-includes/rest-api/class-wp-rest-server.php(1181): Zapier_Auth->generate_token(Object(WP_REST_Request))
#2 /dom24460/wp-includes/rest-api/class-wp-rest-server.php(1028): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/zapier/v1/toke...', Array, NULL)
#3 /dom24460/wp-includes/rest-api/class-wp-rest-server.php(442): WP_REST_Server->dispatch(Object(WP_REST_Request))
#4 /dom24460/wp-includes/rest-api.php(410): WP_REST_Server->serve_request('/zapier/v1/toke...')
#5 /dom24460/wp-includes/class-wp-hook.php(308): rest_api_loaded(Object(WP))
#6 /dom24460/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#7 /dom24460/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#8 /dom24460/wp-includes/class-wp.php(399): do_action_ref_array('parse_request', Array)
#9 /dom24460/wp-includes/class-wp.php(780): WP->parse_request('')
#10 /dom24460/wp-includes/functions.php(1334): WP->main('')
#11 /dom24460/wp-blog-header.php(16): wp()
#12 /dom24460/index.php(17): require('/dom24460/wp-bl...')
#13 {main}
  thrown in /dom24460/wp-content/plugins/wp-graphql-woocommerce-2/vendor/firebase/php-jwt/src/JWT.php on line 184

To Reproduce Steps to reproduce the behavior:

  1. Install the Zapier plugin for WordPress
  2. Go to Zapier, create a new zap, and try to authenticate
  3. You will receive a 500 error, and see the error above in WooCommerce logs

Expected behavior Deactivating the wp-graphql-woocommerce plugin fixes the issue and allows Zapier to authenticate.

Plugin Versions

One way I know of to fix this issue is to prefix the php-jwt library using strauss. Let me know if you are open to that and I can submit a PR.

Thanks!

kidunot89 commented 1 year ago

@sbolinger-godaddy Looks like @justlevine beat you to the punch #762

justlevine commented 1 year ago

@sbolinger-godaddy rn #762 is breaking (I think due to a conflict with the dev-deps added in the build process, or maybe the config.php version), but if you have a moment id love a second set of eyes!

sbolinger-godaddy commented 1 year ago

@justlevine @kidunot89 great work guys, thanks!

kidunot89 commented 1 year ago

@sbolinger-godaddy I made a slight regression in my fix but I'll have it resolved by EOD