woocommerce / wc-smooth-generator

Smooth product, customer and order generation for WooCommerce
309 stars 49 forks source link

Fix fatal when default_locale is empty #142

Closed msaggiorato closed 2 months ago

msaggiorato commented 2 months ago

All Submissions:

Changes proposed in this Pull Request:

Fixes a fatal error when trying to generate orders. Some countries may have an empty "default_locale" property. In which case, this would throw a fatal (at least in PHP 8).

There's actually, only one case of this here, so I guess I was "lucky" to hit this. This issue should be fixed separately in Woo itself, but checking here to avoid a fatal wouldn't be bad either IMO.

How to test the changes in this Pull Request:

  1. Check out trunk
  2. Run wp eval "var_dump( WC\SmoothGenerator\Generator\CustomerInfo::generate_person('MV') );"
  3. See fatal
  4. Check out this branch
  5. Run wp eval "var_dump( WC\SmoothGenerator\Generator\CustomerInfo::generate_person('MV') );"
  6. See success

Other information:

Changelog entry

Fix fatal when generating a large amount of orders, which increases the chances of hitting the empty locale issue.

FOR PR REVIEWER ONLY:

coreymckrill commented 2 months ago

Opened a separate issue to fix the default_locale value for MV: https://github.com/woocommerce/woocommerce/issues/50322