diff --git a/plugins/woocommerce-admin/src/Schedulers/ImportScheduler.php b/plugins/woocommerce-admin/src/Schedulers/ImportScheduler.php index d01b5abb451..718f9f65449 100644 --- a/plugins/woocommerce-admin/src/Schedulers/ImportScheduler.php +++ b/plugins/woocommerce-admin/src/Schedulers/ImportScheduler.php @@ -38,8 +38,18 @@ abstract class ImportScheduler { 'group' => self::$group, ) ); + if ( empty( $pending_jobs ) ) { + $in_progress = self::queue()->search( + array( + 'status' => 'in-progress', + 'per_page' => 1, + 'search' => 'import', + 'group' => self::$group, + ) + ); + } - return ! empty( $pending_jobs ); + return ! empty( $pending_jobs ) || ! empty( $in_progress ); } /** diff --git a/plugins/woocommerce-admin/src/Schedulers/SchedulerTraits.php b/plugins/woocommerce-admin/src/Schedulers/SchedulerTraits.php index 4c142e717c9..52dd9c340c5 100644 --- a/plugins/woocommerce-admin/src/Schedulers/SchedulerTraits.php +++ b/plugins/woocommerce-admin/src/Schedulers/SchedulerTraits.php @@ -234,7 +234,11 @@ trait SchedulerTraits { if ( is_array( $blocking_jobs ) ) { foreach ( $blocking_jobs as $blocking_job ) { $blocking_job_hook = $blocking_job->get_hook(); - $next_job_schedule = $blocking_job->get_schedule()->next(); + if ( method_exists( $blocking_job->get_schedule(), 'get_date' ) ) { + $next_job_schedule = $blocking_job->get_schedule()->get_date(); + } else { + $next_job_schedule = $blocking_job->get_schedule()->next(); + } // Ensure that the next schedule is a DateTime (it can be null). if ( is_a( $next_job_schedule, 'DateTime' ) ) {