You are here

function ultimate_cron_get_schedule in Ultimate Cron 6

Same name and namespace in other branches
  1. 8 ultimate_cron.module \ultimate_cron_get_schedule()
  2. 7 ultimate_cron.module \ultimate_cron_get_schedule()

Get a list of functions that should be run now.

Parameters

$hooks: Array of cron hooks to check.

Return value

array Functions to run now.

2 calls to ultimate_cron_get_schedule()
drush_ultimate_cron_cron_run in ./ultimate_cron.drush.inc
Run cron job(s)
ultimate_cron_cron in ./ultimate_cron.module
Implementation of hook_cron().

File

./ultimate_cron.module, line 926
@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_get_schedule($hooks, $schedule_unsafe = FALSE) {

  // Create list of scheduled functions
  $schedule = array();
  foreach ($hooks as $name => &$hook) {
    ultimate_cron_load_hook_data($hook);

    // Is it safe?
    if (!$schedule_unsafe && $hook['unsafe']) {
      continue;
    }

    // Store last run in hook for sorting purposes
    $last_run = isset($hook['log']['start']) ? $hook['log']['start'] : 0;
    $hook['last_run'] = $last_run;
    if (ultimate_cron_hook_should_run($hook)) {
      $schedule[$name] = $hook;
    }
  }

  // Sort by last run time
  uasort($schedule, '_ultimate_cron_sort_schedule');

  // Allow other to manipulate the schedule
  drupal_alter('cron_schedule', $schedule);
  return $schedule;
}