You are here

public function UltimateCronBackgroundProcessLegacyLauncher::lock in Ultimate Cron 7.2

Lock job.

Background Process doesn't internally provide a unique id for the running process, so we'll have to add that ourselves. We store the unique lock id in the second callback argument.

Overrides UltimateCronLauncher::lock

File

plugins/ultimate_cron/launcher/background_process_legacy.class.php, line 250
Background Process 1.x launcher for Ultimate Cron.

Class

UltimateCronBackgroundProcessLegacyLauncher
Ultimate Cron launcher plugin class.

Code

public function lock($job) {
  $handle = 'uc-' . $job->name;
  $process = new BackgroundProcess($handle);
  if (!$process
    ->lock()) {
    return FALSE;
  }
  $lock_id = $job->name . ':' . uniqid('bgpl', TRUE);
  global $user;
  background_process_set_process($process->handle, '__LOCKED__', $user->uid, array(
    $job->name,
    $lock_id,
  ), $process->token);
  return $lock_id;
}