public static function abortDbBatchJob(BatchJob $dbBatchJob, $force = false) { // No need to abort finished job if (in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) { if ($force) { $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED); $dbBatchJob->save(); } return $dbBatchJob; } $lockObject = $dbBatchJob->getBatchJobLock(); if (is_null($lockObject)) { KalturaLog::err("Batch job [" . $dbBatchJob->getId() . "] doesn't have a lock object and can't be deleted. Status (" . $dbBatchJob->getStatus() . ")"); return $dbBatchJob; } // Update status $con = Propel::getConnection(); $update = new Criteria(); $update->add(BatchJobLockPeer::STATUS, BatchJob::BATCHJOB_STATUS_ABORTED); $update->add(BatchJobLockPeer::VERSION, $lockObject->getVersion() + 1); $updateCondition = new Criteria(); $updateCondition->add(BatchJobLockPeer::ID, $lockObject->getId(), Criteria::EQUAL); $updateCondition->add(BatchJobLockPeer::VERSION, $lockObject->getVersion(), Criteria::EQUAL); $updateCondition->add(BatchJobLockPeer::SCHEDULER_ID, null, Criteria::ISNULL); $affectedRows = BasePeer::doUpdate($updateCondition, $update, $con); if ($affectedRows) { $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED); $dbBatchJob = self::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_ABORTED); } else { $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED); $dbBatchJob->save(); } self::abortChildJobs($dbBatchJob); return $dbBatchJob; }