Commit 7902168c525 for woocommerce
commit 7902168c5258ddd60c2c417b463c381a33d75be2
Author: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
Date: Thu Oct 29 13:18:58 2026 -0700
Migrate the order sync and unpaid-order scheduling calls to ActionSchedulerUtil (#70152)
DataSynchronizer schedules its background sync through the util. wc_cancel_unpaid_orders() drops its explicit unique = false argument and records why that call must not be unique.
Split from #69847 (WOOPLUG-2435).
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/update-wooplug-2435-migrate-as-calls-orders b/plugins/woocommerce/changelog/update-wooplug-2435-migrate-as-calls-orders
new file mode 100644
index 00000000000..015a2bb07cd
--- /dev/null
+++ b/plugins/woocommerce/changelog/update-wooplug-2435-migrate-as-calls-orders
@@ -0,0 +1,3 @@
+Significance: patch
+Type: update
+Comment: Covered by the base PR changelog entry (#69846).
diff --git a/plugins/woocommerce/includes/wc-order-functions.php b/plugins/woocommerce/includes/wc-order-functions.php
index bcca2af89d5..628c8191198 100644
--- a/plugins/woocommerce/includes/wc-order-functions.php
+++ b/plugins/woocommerce/includes/wc-order-functions.php
@@ -1147,8 +1147,9 @@ function wc_cancel_unpaid_orders() {
}
// Schedule the next event using Action Scheduler if available, otherwise fall back to WordPress cron.
+ // Not unique: this runs inside the action itself, and a unique check would see the in-progress run and schedule nothing.
if ( function_exists( 'as_schedule_single_action' ) ) {
- as_schedule_single_action( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders', array(), 'woocommerce', false );
+ as_schedule_single_action( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders', array(), 'woocommerce' );
} else {
wp_schedule_single_event( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
}
diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php b/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php
index 951135226f9..c8a6e964e4b 100644
--- a/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php
+++ b/plugins/woocommerce/src/Internal/DataStores/Orders/DataSynchronizer.php
@@ -9,6 +9,7 @@ use Automattic\WooCommerce\Caches\OrderCacheController;
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
use Automattic\WooCommerce\Internal\Admin\Orders\EditLock;
use Automattic\WooCommerce\Internal\BatchProcessing\{ BatchProcessingController, BatchProcessorInterface };
+use Automattic\WooCommerce\Internal\Utilities\ActionSchedulerUtil;
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
use Automattic\WooCommerce\Proxies\LegacyProxy;
@@ -384,8 +385,7 @@ class DataSynchronizer implements BatchProcessorInterface {
private function schedule_background_sync() {
$interval = $this->get_background_sync_interval();
- // Calling Action Scheduler directly because WC_Action_Queue doesn't support the unique parameter yet.
- as_schedule_recurring_action(
+ ActionSchedulerUtil::schedule_recurring(
time() + $interval,
$interval,
self::BACKGROUND_SYNC_EVENT_HOOK,