function ultimate_cron_should_run in Ultimate Cron 6
Same name and namespace in other branches
- 8 ultimate_cron.module \ultimate_cron_should_run()
- 7 ultimate_cron.module \ultimate_cron_should_run()
Check if rule is scheduled to run at a given time.
Parameters
$rules: rules to validate.
$last_run: last time the rule was run.
$now: time of validation, set to NULL for now.
$catch_up: run if we missed our time window?
Return value
boolean TRUE if rule is scheduled to run, FALSE if not.
2 calls to ultimate_cron_should_run()
- UltimateCronRulesUnitTestCase::runTest in tests/
rules.test - ultimate_cron_hook_should_run in ./
ultimate_cron.module - Check if a hook should be run now.
File
- ./
ultimate_cron.module, line 1260 - @todo Add filter on overview page. @todo Add log view (with graph). @todo Make proper markup for overview page. @todo Refactor drush stuff, too many intimate relations with Background Process @todo Refactor Cron % offset stuff. Too mixed up and…
Code
function ultimate_cron_should_run($rules, $job_last_ran, $now = NULL, $catch_up = 0, $offset = 0) {
$now = is_null($now) ? time() : $now;
require_once 'CronRule.class.php';
$cron = new CronRule();
foreach ($rules as $rule) {
$cron->rule = $rule;
$cron->offset = $offset;
$cron_last_ran = $cron
->getLastRan($now);
if ($job_last_ran < $cron_last_ran && $cron_last_ran <= $now) {
if ($now <= $cron_last_ran + $catch_up) {
return TRUE;
}
}
}
return FALSE;
}