Refresh data source poller transients on wc_admin_daily (#37027)

* Refresh data source poller transients on wc_admin_daily

* Add changelog

* Conditionally refresh data source pollers

* Fix style

* Check  woocommerce-pyaments -- woocommerce-payments can override payments task

* Add marketing task check for RemoteFreeExtensionsDataSourcePoller
This commit is contained in:
Moon 2023-03-20 11:30:48 -07:00 committed by GitHub
parent 1f177d23c0
commit 679339ec95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Refresh data source poller transients on wc_admin_daily

View File

@ -44,6 +44,8 @@ use Automattic\WooCommerce\Internal\Admin\Notes\WooCommerceSubscriptions;
use Automattic\WooCommerce\Internal\Admin\Notes\WooSubscriptionsNotes; use Automattic\WooCommerce\Internal\Admin\Notes\WooSubscriptionsNotes;
use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler; use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
use Automattic\WooCommerce\Admin\Notes\Note; use Automattic\WooCommerce\Admin\Notes\Note;
use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\PaymentGatewaySuggestionsDataSourcePoller;
use Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions\RemoteFreeExtensionsDataSourcePoller;
/** /**
* Events Class. * Events Class.
@ -143,6 +145,7 @@ class Events {
$this->possibly_add_notes(); $this->possibly_add_notes();
$this->possibly_delete_notes(); $this->possibly_delete_notes();
$this->possibly_update_notes(); $this->possibly_update_notes();
$this->possibly_refresh_data_source_pollers();
if ( $this->is_remote_inbox_notifications_enabled() ) { if ( $this->is_remote_inbox_notifications_enabled() ) {
DataSourcePoller::get_instance()->read_specs_from_data_sources(); DataSourcePoller::get_instance()->read_specs_from_data_sources();
@ -250,4 +253,21 @@ class Events {
// All checks have passed. // All checks have passed.
return true; return true;
} }
/**
* Refresh transient for the following DataSourcePollers on wc_admin_daily cron job.
* - PaymentGatewaySuggestionsDataSourcePoller
* - RemoteFreeExtensionsDataSourcePoller
*/
protected function possibly_refresh_data_source_pollers() {
$completed_tasks = get_option( 'woocommerce_task_list_tracked_completed_tasks' );
if ( ! in_array( 'payments', $completed_tasks, true ) && ! in_array( 'woocommerce-payments', $completed_tasks, true ) ) {
PaymentGatewaySuggestionsDataSourcePoller::get_instance()->read_specs_from_data_sources();
}
if ( ! in_array( 'store_details', $completed_tasks, true ) && ! in_array( 'marketing', $completed_tasks, true ) ) {
RemoteFreeExtensionsDataSourcePoller::get_instance()->read_specs_from_data_sources();
}
}
} }