taxjar / taxjar-woocommerce-plugin

WooCommerce Sales Tax Plugin by TaxJar
http://www.taxjar.com/woocommerce-sales-tax-plugin/
GNU General Public License v2.0
28 stars 29 forks source link

Update class-wc-taxjar-nexus.php #249

Open MillerMedia opened 10 months ago

MillerMedia commented 10 months ago

Describe the problem (reference the issue if applicable) and what the PR accomplishes.

Steps to Reproduce

Receiving this error in a WPEngine hosting environment. We do not know what triggered it but we did see that sometimes $this->nexus can be null in this function in certain instances. Added a simply null check:

Error Details

An error of type E_ERROR was caused in line 24 of the file /nas/content/live/oursite/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-wc-taxjar-nexus.php. Error message: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /nas/content/live/oursite/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-wc-taxjar-nexus.php:24 Stack trace:

0 /nas/content/live/oursite/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-taxjar-settings.php(330): WC_Taxjar_Nexus->get_form_settings_field() #1 /nas/content/live/oursite/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-taxjar-settings.php(208): TaxJar_Settings::get_nexus_settings_display() #2 /nas/content/live/oursite/wp-content/plugins/taxjar-simplified-taxes-for-woocommerce/includes/class-taxjar-settings.php(645): TaxJar_Settings::get_settings() #3 /nas/content/live/oursite/wp-includes/class-wp-hook.php(310): TaxJar_Settings::save('') #4 /nas/content/live/oursite/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array) #5 /nas/content/live/oursite/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #6 /nas/content/live/oursite/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-settings.php(77): do_action('woocommerce_set...') #7 /nas/content/live/oursite/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-menus.php(153): WC_Admin_Settings::save() #8 /nas/content/live/oursite/wp-includes/class-wp-hook.php(310): WC_Admin_Menus->save_settings('') #9 /nas/content/live/oursite/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array) #10 /nas/content/live/oursite/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #11 /nas/content/live/oursite/wp-settings.php(654): do_action('wp_loaded') #12 /nas/content/live/oursite/wp-config.php(121): require_once('/nas/content/li...') #13 /nas/content/live/oursite/wp-load.php(50): require_once('/nas/content/li...') #14 /nas/content/live/oursite/wp-admin/admin.php(34): require_once('/nas/content/li...') #15 {main}

thrown

Expected Result

No error should be thrown when $this->nexus is null and the admin page with settings is visited.

Click-Test Versions

Specs Passing

CLAassistant commented 10 months ago

CLA assistant check
All committers have signed the CLA.

gabriele-mwd commented 1 week ago

Hi, I'm facing quite the same issue but the problem in my case is that $this->nexus is a string, which is not countable, and that is causing a fatal error, too. I would suggest to replace !is_null( $this->nexus ) with is_countable( $this->nexus ).

I've also noticed that this PR was opened one year ago and it hasn't been merged yet. Is the TaxJar team still active?