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
Bypass scheduled actions for customer updates #37265
Bypass scheduled actions for customer updates #37265
Conversation
874ae72
to
5753924
Compare
5753924
to
4356684
Compare
Test Results SummaryCommit SHA: 26aa5a3
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. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37265 +/- ##
==========================================
- Coverage 46.7% 46.7% -0.0%
- Complexity 17191 17195 +4
==========================================
Files 429 429
Lines 64845 64878 +33
==========================================
+ Hits 30275 30284 +9
- Misses 34570 34594 +24
|
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.
Tested fine and code looks good, nice job!. Just left a suggestion on one part.
@@ -835,6 +861,11 @@ public static function delete_customer( $customer_id ) { | |||
public static function delete_customer_by_user_id( $user_id ) { | |||
global $wpdb; | |||
|
|||
if ( (int) $user_id < 1 || doing_action( 'wp_uninitialize_site' ) ) { |
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.
I'm wondering why this had to be added. In which scenario would this be called with user_id < 1? Maybe it's worth adding a comment?
EDIT: I see you only moved this from the scheduler. Feel free to leave it like this if you think it's OK.
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.
A user ID of 0
would be an unauthenticated request, or some error up the chain that resulted in user ID 0
. Whatever the case, proceeding with the DELETE
would be unnecessary, so the early return seems most robust.
All Submissions:
Changes proposed in this Pull Request:
This PR changes the handling of various types of customer updates to update the Analytics lookup tables immediately instead of using Action Scheduler, to decrease the load on Action Scheduler and improve overall site performance.
woocommerce_new_customer
)woocommerce_update_customer
,updated_user_meta
)delete_user
,remove_user_from_blog
)woocommerce_privacy_remove_order_personal_data
)Closes #36330.
How to test the changes in this Pull Request:
Have you followed the Writing high-quality testing instructions guide?
The Customers report can be found at WooCommerce > Customers (
/wp-admin/admin.php?page=wc-admin&path=%2Fcustomers
)General store settings to configure prior to testing
New customer is created (actions:
woocommerce_new_customer
)or use the REST API (doc) to create a new customer...
wc-admin_import_customers
appears in Tools > Scheduled Actions.Customer updated (actions:
woocommerce_update_customer
,updated_user_meta
,added_user_meta
)wc-admin_import_customers
appears in Tools > Scheduled Actions.wc_last_active
entry fromwp_usermeta
for the customer's record.wc-admin_import_customers
appears in Tools > Scheduled Actions.Customer deleted (actions
delete_user
,remove_user_from_blog
)wc-admin_delete_user_customers
appears in Tools > Scheduled Actions.Personal data removed (action:
woocommerce_privacy_remove_order_personal_data
)Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: