You are here

function elysia_cron_execute_page in Elysia Cron 5

Same name and namespace in other branches
  1. 5.2 elysia_cron.admin.inc \elysia_cron_execute_page()
  2. 6.2 elysia_cron.admin.inc \elysia_cron_execute_page()
  3. 6 elysia_cron.admin.inc \elysia_cron_execute_page()
  4. 7.2 elysia_cron.admin.inc \elysia_cron_execute_page()
  5. 7 elysia_cron.admin.inc \elysia_cron_execute_page()
1 string reference to 'elysia_cron_execute_page'
elysia_cron_menu in ./elysia_cron.module

File

./elysia_cron.admin.inc, line 695

Code

function elysia_cron_execute_page($job = false) {
  global $cron_completed, $cron_executing_job, $conf;
  if (!$job) {
    drupal_set_message(t('No job specified'), 'error');
    drupal_goto(_dcf_internal_path('admin/config/system/cron'));
  }
  $running = false;
  if (elysia_cron_is_job_running($job, false)) {
    if (time() - elysia_cron_get_job_last_run($job, 0) > variable_get('elysia_cron_stuck_time', 3600)) {
      drupal_set_message(t('Job %job already running, but is probably stuck, so i consider it as terminated', array(
        '%job' => $job,
      )));
    }
    else {
      drupal_set_message(t('Job %job already running', array(
        '%job' => $job,
      )));
      $running = true;
    }
  }
  if (!$running) {
    $cron_completed = false;
    $cron_executing_job = $job;
    if (EC_DRUPAL_VERSION < 7) {

      // Some modules (feedapi, ipaper...) uses the internal "cron_semaphore" variable to detect
      // start time of cron process. I'll set this only in memory for that purpose.
      // (In normal drupal cron execution that is done by a variable_set just before this call,
      // but i need to set this manually if drupal cron is bypassed)
      $conf['cron_semaphore'] = time();
    }

    // Register shutdown callback
    register_shutdown_function('elysia_cron_execute_page_cleanup');
    elysia_cron_initialize();
    elysia_cron_execute($job);
    if (EC_DRUPAL_VERSION < 7) {
      _ec_variable_del('cron_semaphore');
      $conf['cron_semaphore'] = false;
    }
    $cron_completed = true;
    drupal_set_message(t('Job executed'));
  }
  drupal_goto(_dcf_internal_path('admin/config/system/cron'));
}