You are here

function ultimate_cron_run_hook in Ultimate Cron 7

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

Run a cron hook. Launches the cron job in a background process

Parameters

$name:

$hook:

Return value

mixed Connections file handle on success.

3 calls to ultimate_cron_run_hook()
drush_ultimate_cron_cron_run in ./ultimate_cron.drush.inc
Run cron job(s)
ultimate_cron_cron_run in ./ultimate_cron.module
The cron handler takes over the normal Drupal cron handler and runs the normal hook_cron() plus the hook_cronapi().
ultimate_cron_service_start in ./ultimate_cron.admin.inc
Run a single function.

File

./ultimate_cron.module, line 828
@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_run_hook($name, $hook) {

  // Run the job in background
  $result = NULL;
  $handle_prefix = variable_get('ultimate_cron_handle_prefix', ULTIMATE_CRON_HANDLE_PREFIX);
  $handle = $handle_prefix . $name;
  $process = new BackgroundProcess($handle);

  // Always run cron job as anonymous user
  $process->uid = 0;

  // Determine service group
  $process->service_group = empty($hook['settings']['service_group']) ? variable_get('ultimate_cron_service_group', ULTIMATE_CRON_SERVICE_GROUP) : $hook['settings']['service_group'];
  $hook['timestamp'] = time();
  unset($hook['log']['msg']);
  $result = $process
    ->start('_ultimate_cron_run_hook', array(
    $name,
    $hook,
  ));
  return $result ? $process->connection : $result;
}