public function UltimateCronBackgroundProcessLegacyLauncher::isLockedMultiple in Ultimate Cron 7.2
Check locked state for multiple jobs.
This has yet to be optimized.
Overrides UltimateCronLauncher::isLockedMultiple
File
- plugins/
ultimate_cron/ launcher/ background_process_legacy.class.php, line 301 - Background Process 1.x launcher for Ultimate Cron.
Class
- UltimateCronBackgroundProcessLegacyLauncher
- Ultimate Cron launcher plugin class.
Code
public function isLockedMultiple($jobs) {
$handles = array();
foreach ($jobs as $job) {
$handles[] = 'uc-' . $job->name;
}
try {
$old_db = db_set_active('background_process');
$processes = db_select('background_process', 'bp')
->fields('bp', array(
'handle',
'args',
))
->condition('handle', $handles, 'IN')
->execute()
->fetchAllAssoc('handle', PDO::FETCH_OBJ);
db_set_active($old_db);
} catch (Throwable $e) {
db_set_active($old_db);
throw $e;
} catch (Exception $e) {
db_set_active($old_db);
throw $e;
}
$lock_ids = array();
foreach ($jobs as $job) {
$lock_ids[$job->name] = FALSE;
if (isset($processes['uc-' . $job->name])) {
$process = $processes['uc-' . $job->name];
$process->args = unserialize($process->args);
$lock_ids[$job->name] = $process->args[1];
}
}
return $lock_ids;
}