You are here

function ultimate_cron_service_start in Ultimate Cron 6

Same name and namespace in other branches
  1. 8 ultimate_cron.admin.inc \ultimate_cron_service_start()
  2. 7 ultimate_cron.admin.inc \ultimate_cron_service_start()

Run a single function.

Parameters

$function:

Return value

string Output to page

1 string reference to 'ultimate_cron_service_start'
ultimate_cron_menu in ./ultimate_cron.module
Implementation of hook_menu().

File

./ultimate_cron.admin.inc, line 547

Code

function ultimate_cron_service_start($function) {
  $hooks = ultimate_cron_get_hooks();
  if (!isset($hooks[(string) $function])) {
    drupal_not_found();
    exit;
  }
  if ($modules = _ultimate_cron_incompatible_modules()) {
    drupal_set_message(t('%function could not start (incompatible module installed)', array(
      '%function' => $function,
    )), 'error');
    drupal_set_message(t('%modules is installed on the system, but is incompatible with Ultimate Cron.<br/>Please disable the conflicting modules.<br/>You might want to !url settings first.', array(
      '%modules' => join(', ', $modules),
      '!url' => l(t('import'), 'admin/settings/cron/import'),
    )), 'error');
    drupal_goto();
  }
  if (!empty($hooks['unsafe'])) {
    drupal_set_message(t('%function could not start (unsafe)', array(
      '%function' => $function,
    )), 'error');
    drupal_goto();
  }

  // When run manually don't double check the rules
  $hooks[$function]['skip_catch_up'] = TRUE;
  ultimate_cron_load_hook_data($hooks[$function]);
  $handle = ultimate_cron_run_hook($function, $hooks[$function]);
  if ($handle === FALSE) {
    drupal_set_message(t('%function could not start (already running?)', array(
      '%function' => $function,
    )), 'error');
  }
  elseif ($handle === NULL) {
    drupal_set_message(t('%function could not start (service unavailable)', array(
      '%function' => $function,
    )), 'error');
  }
  else {
    drupal_set_message(t('%function started', array(
      '%function' => $function,
    )));
  }
  drupal_goto();
}