Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This logic could be improved:
while ($job = db_fetch_array($result)) {
// Flag periodic jobs as scheduled, remove one-off jobs.
if ($job['periodic']) {
$job['scheduled'] = $job['last'] = JOB_SCHEDULER_REQUEST_TIME;
$job['next'] = $job['period'] + JOB_SCHEDULER_REQUEST_TIME;
drupal_write_record('job_schedule', $job, array('callback', 'type', 'id'));
}
else {
$this->remove($job);
}
// Queue job if there is a queue declared for it, otherwise execute it.
if (function_exists($job['callback'])) {
if (!$this->queue($job)) {
$job['callback']($job);
}
}
Why the record of non-periodic job is removed first, before job is executed?
What if callback execution is not finished, took too long, or something?
Logically for me should be execute the job, and after it's successful, remove it.
Comments
Comment #1
mstrelan CreditAttribution: mstrelan commented+1
Comment #2
twistor CreditAttribution: twistor commentedIf the job is unsuccessful, has a fatal error, takes too long, then it shouldn't run again.