Commit 08a9bcb712 for woocommerce
commit 08a9bcb712255fe229b7ccbdf867802c8ea170cc
Author: Herman <KokkieH@users.noreply.github.com>
Date: Tue Jan 6 16:33:47 2026 +0200
Include source in request body if request is triggered by Refresh button on my subscriptions (#62674)
* Include source in request body if request is triggered by Refresh button on my subscriptions
* Fix string that is checked to detect my-subscriptions request source
* Improve stripos checks in WC_Helper::get_subscripions() to guard against matches at position 0 evaluating as falsey.
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
diff --git a/plugins/woocommerce/changelog/62674-update-WCCOM-1895-bypass-rate-limit-refresh-request b/plugins/woocommerce/changelog/62674-update-WCCOM-1895-bypass-rate-limit-refresh-request
new file mode 100644
index 0000000000..99fdeb0ab5
--- /dev/null
+++ b/plugins/woocommerce/changelog/62674-update-WCCOM-1895-bypass-rate-limit-refresh-request
@@ -0,0 +1,4 @@
+Significance: minor
+Type: tweak
+
+- Includes a source parameter for requests to the `/update-check` and `/subscriptions` endpoints on WooCommerce.com if the request originates from the Refresh button on My Subscriptions - Fix source parameter for other requests to the `/subscriptions` endpoint originating from the My Subscriptions page
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/admin/helper/class-wc-helper-updater.php b/plugins/woocommerce/includes/admin/helper/class-wc-helper-updater.php
index bbd98c7836..75bbce882a 100644
--- a/plugins/woocommerce/includes/admin/helper/class-wc-helper-updater.php
+++ b/plugins/woocommerce/includes/admin/helper/class-wc-helper-updater.php
@@ -659,11 +659,23 @@ class WC_Helper_Updater {
'errors' => array(),
);
+ // Detect if this is a manual refresh button click.
+ $request_uri = wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ $source = '';
+ if ( stripos( $request_uri, 'wc/v3/marketplace/refresh' ) !== false ) {
+ $source = 'refresh-button';
+ }
+
+ $request_body = array( 'products' => $payload );
+ if ( ! empty( $source ) ) {
+ $request_body['source'] = $source;
+ }
+
if ( WC_Helper::is_site_connected() ) {
$request = WC_Helper_API::post(
'update-check',
array(
- 'body' => wp_json_encode( array( 'products' => $payload ) ),
+ 'body' => wp_json_encode( $request_body ),
'authenticated' => true,
)
);
@@ -671,7 +683,7 @@ class WC_Helper_Updater {
$request = WC_Helper_API::post(
'update-check-public',
array(
- 'body' => wp_json_encode( array( 'products' => $payload ) ),
+ 'body' => wp_json_encode( $request_body ),
)
);
}
diff --git a/plugins/woocommerce/includes/admin/helper/class-wc-helper.php b/plugins/woocommerce/includes/admin/helper/class-wc-helper.php
index 69d7e7f630..9580154323 100644
--- a/plugins/woocommerce/includes/admin/helper/class-wc-helper.php
+++ b/plugins/woocommerce/includes/admin/helper/class-wc-helper.php
@@ -1844,15 +1844,17 @@ class WC_Helper {
try {
$request_uri = wp_unslash( $_SERVER['REQUEST_URI'] ?? '' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$source = '';
- if ( stripos( $request_uri, 'wc-addons' ) ) :
+ if ( false !== stripos( $request_uri, 'wc/v3/marketplace/refresh' ) ) :
+ $source = 'refresh-button';
+ elseif ( false !== stripos( $request_uri, 'my-subscriptions' ) ) :
$source = 'my-subscriptions';
- elseif ( stripos( $request_uri, 'plugins.php' ) ) :
+ elseif ( false !== stripos( $request_uri, 'plugins.php' ) ) :
$source = 'plugins';
- elseif ( stripos( $request_uri, 'wc-admin' ) ) :
+ elseif ( false !== stripos( $request_uri, 'wc-admin' ) ) :
$source = 'inbox-notes';
- elseif ( stripos( $request_uri, 'admin-ajax.php' ) ) :
+ elseif ( false !== stripos( $request_uri, 'admin-ajax.php' ) ) :
$source = 'heartbeat-api';
- elseif ( stripos( $request_uri, 'installer' ) ) :
+ elseif ( false !== stripos( $request_uri, 'installer' ) ) :
$source = 'wccom-site-installer';
elseif ( defined( 'WP_CLI' ) && WP_CLI ) :
$source = 'wc-cli';