You are here

function elysia_cron_cron in Elysia Cron 6.2

Same name and namespace in other branches
  1. 5.2 elysia_cron.module \elysia_cron_cron()
  2. 5 elysia_cron.module \elysia_cron_cron()
  3. 6 elysia_cron.module \elysia_cron_cron()
  4. 7.2 elysia_cron.module \elysia_cron_cron()
  5. 7 elysia_cron.module \elysia_cron_cron()

Hook cron is invoked only by standard drupal cron. It's used to replace drupal cron.

File

./elysia_cron.module, line 138

Code

function elysia_cron_cron() {
  global $elysia_cron_exit_phase, $elysia_cron_drush;

  // If invoked "core-cron" via drush i'll redirect to elysia-cron handler
  if (function_exists('elysia_cron_drush_detect') && elysia_cron_drush_detect()) {
    elysia_cron_drush_invoke(true);
  }

  // First cron run is executed in standard drupal way. This is to enable the use of install profiles
  if (variable_get('cron_last', 0) == 0) {
    return;
  }

  // If the path is 'admin/*', or if the user is not anonymous, this is a manual cron run (probably by admin/logs/status), but not if we are in the exit phase (= this a "poormanscron" run)
  $manual_run = empty($elysia_cron_exit_phase) && (arg(0) == 'admin' || !empty($GLOBALS['user']->uid));
  $result = elysia_cron_run($manual_run);
  drupal_clean_after_cron_run();
  if ($manual_run) {
    if ($result) {
      elysia_cron_message('Cron ran successfully');
    }
    else {
      elysia_cron_message('Cron run failed, disabled or nothing to do');
    }

    // In manual execution it's better to set cron_last variable in standard way (so the user sees the execution time updates). This invalidates variable cache, but it's a manual execution, it should be not a great performance problem.
    if (empty($elysia_cron_drush)) {
      variable_set('cron_last', time());
    }
    drupal_goto(_dcf_internal_path('admin/reports/status'));
  }

  // If we are in "poormanscron" mode it's better to force setting of cron_last. This invalidates variable cache, but is needed for right execution check.
  // @see system_run_automated_cron() in system.module
  if (!empty($elysia_cron_exit_phase)) {
    variable_set('cron_last', time());
  }
  exit;
}