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
Prevent unwanted helper api calls when loading subscription notes #37378
Prevent unwanted helper api calls when loading subscription notes #37378
Conversation
…ge to avoid calling helper API endpoints unnecessarily.
Test Results SummaryCommit SHA: f754dc5
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 #37378 +/- ##
===========================================
- Coverage 51.7% 45.8% -5.9%
+ Complexity 17257 17196 -61
===========================================
Files 429 429
Lines 79689 64911 -14778
===========================================
- Hits 41200 29702 -11498
+ Misses 38489 35209 -3280 |
Hi @rcstr, @psealock, @denho, @vedanshujain, 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: |
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.
Requesting a minor change if its possible
plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php
Outdated
Show resolved
Hide resolved
…subscription-notes
@thilinah This looks good to me, but I am assuming you are waiting for wc-admin folks to also take a look? |
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.
Changes looks good and work as expected
@vedanshujain if the changes look good can you please approve the PR, I see it's blocked due to the change request. |
@thilinah dismissed my review, should be mergeable now |
@thilinah The WC notes are shown not only on |
@denho in this case I think skipping subscription notes loading based on the page won't work. I've noticed that other WC plugins like subscriptions and bookings also show the Due to this, I think we should consider moving forward with #36846 and move the discussion to that PR for refining the approach. |
Also, another way could be to make sure subscription notes are not loaded via the cron. |
Since `get_current_screen` function can not be called within `admin-init` hook it is not possible to determine if the subscriptions are being loaded via WC related page or not.
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.
Changes looks good and works as described
I'm going to clear the milestone from this for now, so that this doesn't inadvertently get missed once it's merged. A milestone will be added automatically by our automation upon merge. |
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.
Added some suggestions in the code. Otherwise, LGTM!
plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php
Outdated
Show resolved
Hide resolved
plugins/woocommerce/src/Internal/Admin/Notes/WooSubscriptionsNotes.php
Outdated
Show resolved
Hide resolved
@jonathansadowski, the PR is approved. Is it possible to get this merged? |
Hi @thilinah, please feel free to merge once checks have passed (as they have in this case), and you've gotten your PR approved. If you don't have access to merge yourself, let me know and I can take a look further. |
@jonathansadowski I'm not authorized to merge. |
Thanks @thilinah, I've merged this for now — I'll look into whether or not that should be the case. |
All Submissions:
Changes proposed in this Pull Request:
Connected WooCommerce stores send requests to helper API for fetching details related to subscriptions and to get information about plugin updates. The responses from these API endpoints are cached to prevent stores from sending multiple requests frequently.
For example, the
GET subscriptions
request is cached for 1 hour andPOST update-check
request is cached for 12 hours.But for some stores, the cache can be completely broken due to DB having a full disk. This is because when
set_transient
is called if the object cache is not configured for the site wp options table will be used to store the transient value. (further discussions in this P2 post and the issue).Problem
admin_init
admin_init
the optionLAST_REFRESH_OPTION_KEY
is used.Fix
Activity
tab.Closes # .
How to test the changes in this Pull Request:
Cron should not load subscription notes
woocommerce_admin-wc-helper-last-refresh
will be set to the current time. We will use this fact for testing.wp option delete woocommerce_admin-wc-helper-last-refresh
wp cron event run --all
wp option get woocommerce_admin-wc-helper-last-refresh
and notice it exists.wp option delete woocommerce_admin-wc-helper-last-refresh
wp cron event run --all
wp option get woocommerce_admin-wc-helper-last-refresh
and notice it doesn't exist.Only visiting a WC Admin or a page with WC Admin Header Shall load subscription notes
wp option delete woocommerce_admin-wc-helper-last-refresh
wp-admin/edit-comments.php
wp option get woocommerce_admin-wc-helper-last-refresh
and notice it doesn't exist.Activity
tab, such aswp-admin/edit.php?post_type=shop_order
wp option get woocommerce_admin-wc-helper-last-refresh
and notice that it exists. (this means subscription notes are loading on this page)Activity
tab are loading subscription notes.Make sure the subscription notes are loading after this update
wp shell
to remove subscription notes.wp option delete woocommerce_admin-wc-helper-last-refresh
reset last subscription notes refresh time.Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: