Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Validate data coming from "woocommerce_cart_shipping_packages" filter #9016

Open
wavvves opened this issue Apr 12, 2023 · 1 comment
Open
Labels
team: Rubik type: technical debt This issue/PR represents/solves the technical debt of the project.

Comments

@wavvves
Copy link
Contributor

wavvves commented Apr 12, 2023

Describe the bug

A Warning/ TypeError (depending on PHP version used) is displayed on the front end when Multiple Packages for WooCommerce is activated but not yet configured, while WooCommerce Stripe Gateway is enabled and configured.

To reproduce

Steps to reproduce the behavior:

  1. Install and activate Multiple Packages for WooCommerce without setting it up
  2. Install, activate, and set Test Keys for WooCommerce Stripe Gateway
  3. Add an item to the cart and visit the Cart Block page
  4. See Warning/TypeError:

image

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php:604 
Stack trace: 
#0 woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php(879): WC_Stripe_Payment_Request->allowed_items_in_cart() 
#1 woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php(757): WC_Stripe_Payment_Request->should_show_payment_request_button() 
#2 wp-includes/class-wp-hook.php(308): WC_Stripe_Payment_Request->scripts('') 
#3 wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) 
#4 wp-includes/plugin.php(517): WP_Hook->do_action(Array) 
#5 wp-includes/script-loader.php(2194): do_action('wp_enqueue_scri...') 
#6 wp-includes/class-wp-hook.php(308): wp_enqueue_scripts('') 
#7 wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) 
#8 wp-includes/plugin.php(517): WP_Hook->do_action(Array) 
#9 wp-includes/general-template.php(3049): do_action('wp_head') 
#10 wp-content/themes/storefront/header.php(18): wp_head() 
#11 wp-includes/template.php(783): require_once('...') 
#12 wp-includes/template.php(718): load_template('...', true, Array) 
#13 wp-includes/general-template.php(48): locate_template(Array, true, true, Array) 
#14 wp-content/themes/storefront/page.php(13): get_header() 
#15 wp-includes/template-loader.php(106): include('...') 
#16 wp-blog-header.php(19): require_once('...') 
#17 index.php(17): require('...') 
#18 {main} 
thrown in woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php on line 604

Expected behavior

No Warning/Error should be displayed.

Additional context

The problem seems to be the output of "woocommerce_cart_shipping_packages" filter, as it is expecting an array explicitly (L828 rules out object implementing Countable).

Note: This could be a good opportunity to revisit the TODO comment and address the duplicate code present there.

@wavvves wavvves added type: bug The issue/PR concerns a confirmed bug. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. Contributor Day - H1 2023 priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Apr 12, 2023
@wavvves wavvves removed the priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. label Apr 19, 2023
@github-actions
Copy link
Contributor

This issue has been marked as stale because it has not seen any activity within the past 60 days. Our team uses this tool to help surface issues for review. If you are the author of the issue there's no need to comment as it will be looked at.

@github-actions github-actions bot added the status: stale Stale issues and PRs have had no updates for 60 days. label Jun 24, 2023
@wavvves wavvves added type: technical debt This issue/PR represents/solves the technical debt of the project. and removed status: stale Stale issues and PRs have had no updates for 60 days. type: bug The issue/PR concerns a confirmed bug. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. Contributor Day - H1 2023 labels Nov 29, 2023
@wavvves wavvves self-assigned this Nov 29, 2023
@wavvves wavvves added this to the 11.7.0 milestone Nov 29, 2023
@Aljullu Aljullu removed this from the 11.7.0 milestone Dec 4, 2023
@wavvves wavvves removed their assignment Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team: Rubik type: technical debt This issue/PR represents/solves the technical debt of the project.
Projects
None yet
Development

No branches or pull requests

3 participants