Skip to content
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

Fix RIM rules processor #38312

Merged
merged 15 commits into from May 29, 2023
Merged

Fix RIM rules processor #38312

merged 15 commits into from May 29, 2023

Conversation

octaedro
Copy link
Contributor

@octaedro octaedro commented May 16, 2023

Submission Review Guidelines:

Changes proposed in this Pull Request:

This PR introduces code to accurately parse the siteurl during the execution of the remote inbox messages rules processor.
Closes #38167.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Install WooCommerce Payments, WC Beta tester or WC-Admin Test Helper.
  2. To facilitate testing, I created this plugin. Install and activate it.
  3. Go to Tools > WCA Test Helper > Options and delete the options: _transient_timeout_woocommerce_admin_remote_inbox_notifications_specs and _transient_woocommerce_admin_remote_inbox_notifications_specs
  4. Go to Tools > WCA Test Helper > Tools and press the Run button next to Run wc_admin_daily job
  5. The message titled Increase conversions with WooPay — our fastest checkout yet should be visible four times under the Inbox section.

I'm going to add some unit tests in a follow-up PR.

@github-actions github-actions bot added focus: react admin [team:Ghidorah] plugin: woocommerce Issues related to the WooCommerce Core plugin. labels May 16, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 16, 2023

Test Results Summary

Commit SHA: 7057b54

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 51s
E2E Tests1940010020415m 46s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@octaedro octaedro added focus: product management Related to product creation and editing. and removed focus: react admin [team:Ghidorah] labels May 16, 2023
@octaedro octaedro marked this pull request as ready for review May 16, 2023 21:23
@octaedro octaedro requested a review from a team May 16, 2023 21:26
@octaedro octaedro self-assigned this May 16, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 16, 2023

Hi @mattsherman, @louwie17,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@octaedro octaedro marked this pull request as draft May 17, 2023 13:09
@octaedro octaedro marked this pull request as ready for review May 17, 2023 14:21
Copy link
Contributor

@mattsherman mattsherman left a comment

Choose a reason for hiding this comment

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

@octaedro octaedro force-pushed the fix/38167_RIM_rules_processor branch from 63f6cd7 to 5423e4c Compare May 22, 2023 20:10
@octaedro octaedro requested review from a team and mattsherman May 22, 2023 20:11
Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Nice work @octaedro, this is testing well, and the code changes mostly look good, I did leave one suggestion/comment in the option rule processor condition, as it looks a bit confusing, and I am not sure what test cases we could use to better test this.

@@ -25,7 +25,7 @@ public function process( $rule, $stored_state ) {
$default = isset( $rule->default ) ? $rule->default : $default_value;
$option_value = get_option( $rule->option_name, $default );

if ( $is_contains && ! is_array( $option_value ) ) {
if ( $is_contains && ! is_array( $option_value ) && ( ! is_string( $option_value ) || ! is_string( $rule->value ) ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This additional condition is really confusing to me, maybe it would be worth adding a comment here, or is there a way to simplify this?
Why are we also checking if rule->value is not a string? Given the condition only sets the option value to an empty array.

Would $is_contains && ! ( is_array( $option_value ) || is_string( $option_value ) ) be enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it be worth writing some tests around this, to make sure the scenarios are covered.

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Small suggestion in the get_option_value function logic as it breaks all other operations, but otherwise I like the seperation into another function.

@octaedro octaedro requested a review from louwie17 May 26, 2023 17:50
@octaedro
Copy link
Contributor Author

@louwie17 I just addressed the changes you mentioned. Could you take another look at this PR?

Copy link
Contributor

@louwie17 louwie17 left a comment

Choose a reason for hiding this comment

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

Nice work @octaedro, thanks for adding tests and addressing the suggestions, this looks good and tested well, good to 🚢

@octaedro octaedro dismissed mattsherman’s stale review May 29, 2023 12:28

Changes addressed

@octaedro octaedro merged commit 5e3fe64 into trunk May 29, 2023
17 checks passed
@octaedro octaedro deleted the fix/38167_RIM_rules_processor branch May 29, 2023 12:29
@github-actions github-actions bot added this to the 7.9.0 milestone May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: product management Related to product creation and editing. plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote Inbox Notifications rules is matching on system status url rather than the siteurl
3 participants