* add check for in progress actions

* add check for AS get_date() function

* incorporate review feedback

* remove unnecessary else
This commit is contained in:
Ron Rennick 2020-01-08 09:53:05 -04:00 committed by GitHub
parent 76e5483cf2
commit d1f198b21f
2 changed files with 16 additions and 2 deletions

View File

@ -38,8 +38,18 @@ abstract class ImportScheduler {
'group' => self::$group, '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 );
} }
/** /**

View File

@ -234,7 +234,11 @@ trait SchedulerTraits {
if ( is_array( $blocking_jobs ) ) { if ( is_array( $blocking_jobs ) ) {
foreach ( $blocking_jobs as $blocking_job ) { foreach ( $blocking_jobs as $blocking_job ) {
$blocking_job_hook = $blocking_job->get_hook(); $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). // Ensure that the next schedule is a DateTime (it can be null).
if ( is_a( $next_job_schedule, 'DateTime' ) ) { if ( is_a( $next_job_schedule, 'DateTime' ) ) {