-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix 'using null as array index' warning in variable products data store #62452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
$opposite_price_hash was compared against $price_hash but was not checked for null first, causing '$transient_cached_prices_array[ $opposite_price_hash ]' to throw a notice.
Testing GuidelinesHi @jorgeatorres @woocommerce/flux, Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
📝 WalkthroughWalkthroughAdds a changelog entry and tightens a null-check in the WooCommerce variable product data store to avoid accessing an inapplicable Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Confirmed that the warning disappears on this branch.
There are some linting and other failures with this PR, but I trust you'll address them before merging @Konamiman.
Changes proposed in this Pull Request:
In #61286 (later amended in #61472) we introduced a double caching of variation prices for the cases in which prices with and without taxes were the same. As part of this mechanism a
$price_hashand an$opposite_price_hashare calculated (for each of the possible values of$for_display), but at some point anempty( $transient_cached_prices_array[ $opposite_price_hash ] )check is made without first ensuring that$opposite_price_hashis not null: this causes a "Using null as array index" warning. This pull request fixes that.How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
wp eval 'delete_transient("wc_var_prices_<product_id>");'class-wc-product-variable-data-store-cpt.php.Milestone
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment