You are here

function drush_hosting_hosting_task_validate in Hosting 5

File

./task.hosting.inc, line 16

Code

function drush_hosting_hosting_task_validate($task) {
  drush_set_option('user', 1);
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_LOGIN);
  if (is_numeric($task)) {
    $task = node_load($task);
  }
  if ($task->type == 'task') {
    $task->ref = node_load($task->rid);
    $task->changed = mktime();
    $task->executed = mktime();
    $task->revision = true;

    // We remove this from the queue at the start of execution,
    // otherwise, if it takes too long to run it might have a
    // second thread spawned to process it.
    $task->queued = 0;
    node_save($task);
    $task->options = array();
    $task->args = array();

    // create a new revision
    drush_set_context('HOSTING_TASK', $task);
    drush_set_context('DRUSH_LOG_CALLBACK', '_hosting_task_log');
    drush_log(dt("Task starts processing"), 'queue');
  }
  else {
    drush_set_error('HOSTING_INVALID_TASK', t("This task is not valid"));
  }
}