You are here

function _scheduler_run_cron in Scheduler 7

Same name and namespace in other branches
  1. 5 scheduler.module \_scheduler_run_cron()
  2. 6 scheduler.module \_scheduler_run_cron()

Run the lightweight cron.

The Scheduler part of the processing performed here is the same as in the normal Drupal cron run. The difference is that only scheduler_cron() is executed, no other modules hook_cron() functions are called.

This function is called from the external crontab job via url /scheduler/cron or it can be run interactively from the Scheduler configuration page at /admin/config/content/scheduler/cron.

1 call to _scheduler_run_cron()
_scheduler_lightweight_cron_submit in ./scheduler.admin.inc
Form submission handler for _scheduler_lightweight_cron().
1 string reference to '_scheduler_run_cron'
scheduler_menu in ./scheduler.module
Implements hook_menu().

File

./scheduler.cron.inc, line 228
Scheduler cron functions.

Code

function _scheduler_run_cron() {
  $log = variable_get('scheduler_lightweight_log', 1);
  if ($log) {
    watchdog('scheduler', 'Lightweight cron run activated', array(), WATCHDOG_NOTICE);
  }
  scheduler_cron();
  if (ob_get_level() > 0) {
    $handlers = ob_list_handlers();
    if (isset($handlers[0]) && $handlers[0] == 'default output handler') {
      ob_clean();
    }
  }
  if ($log) {
    watchdog('scheduler', 'Lightweight cron run completed', array(), WATCHDOG_NOTICE, l(t('settings'), 'admin/config/content/scheduler/cron'));
  }
  $menu_item = menu_get_item();
  if ($menu_item['path'] == 'admin/config/content/scheduler/cron') {

    // This cron run has been initiated manually from the configuration form.
    // Give a message and return something so that an output page is created.
    // No output should be returned if running from a crontab job.
    if (module_exists('dblog')) {
      drupal_set_message(t('Lightweight cron run completed - see <a href="@url">log</a> for details.', array(
        '@url' => url('admin/reports/dblog'),
      )));
    }
    else {
      drupal_set_message(t('Lightweight cron run completed.'));
    }
    return ' ';
  }

  // drupal_exit() is the proper controlled way to terminate the request, as
  // this will invoke all implementations of hook_exit().
  drupal_exit();
}