Skip to content

Conversation

@wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Aug 12, 2024

Fixes #2411
Additional context:

Changes proposed in this Pull Request:

This PR fixes a fatal error issue that is happening to some merchants. When trying to merge the existing Stripe settings with the updated version, some merchants are getting an error like:

Uncaught TypeError: array_merge(): Argument #2 must be of type array, string given in /wp-content/plugins/woocommerce-gateway-stripe/includes/connect/class-wc-stripe-connect.php:153

or

Uncaught TypeError: array_merge(): Argument #2 must be of type array, bool given in /wp-content/plugins/woocommerce-gateway-stripe/includes/connect/class-wc-stripe-connect.php:153

This means that get_option on includes/connect/class-wc-stripe-connect.php#153 returns an invalid value.

I could not reproduce this issue using PHP 8.1, 8.2, or 8.3 as merchants reported. So, for extra safety, the fix consists of checking if the returning value is a valid array.

Testing instructions

A code review should be enough since no way to reproduce this issue correctly has been found yet. Check if the change looks safe enough for you.

You can also make some tests by hardcoding the value of $current_options (includes/connect/class-wc-stripe-connect.php#153) to different types and connect your Stripe account.


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

cc @diegocurbelo @c-shultz

@wjrosa wjrosa self-assigned this Aug 12, 2024
@wjrosa wjrosa marked this pull request as ready for review August 12, 2024 14:56
@wjrosa wjrosa requested review from a team and diegocurbelo and removed request for a team August 12, 2024 14:58
@wjrosa wjrosa mentioned this pull request Aug 13, 2024
6 tasks
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

Code changes look good.

I tested it by manually editing the saved options to a non array value, and it works as expected 🚢

@wjrosa wjrosa merged commit 4b71491 into develop Aug 14, 2024
@wjrosa wjrosa deleted the fix/fix-connection-array-merge-error branch August 14, 2024 14:15
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.

Compatibility with PHP 8.1

3 participants