Cancel async job when deleting command

This commit is contained in:
nathangray 2019-01-23 09:37:27 -07:00
parent 7fe32caf2c
commit 231946ae58

View File

@ -334,6 +334,7 @@ abstract class admin_cmd
*/ */
function delete() function delete()
{ {
$this->cancel_periodic_job();
if ($this->status != admin_cmd::scheduled) return false; if ($this->status != admin_cmd::scheduled) return false;
$this->status = admin_cmd::deleted; $this->status = admin_cmd::deleted;
@ -1087,7 +1088,7 @@ abstract class admin_cmd
* *
* @return boolean true if job was canceled, false otherwise * @return boolean true if job was canceled, false otherwise
*/ */
protected function cancel_periodic_job() public function cancel_periodic_job()
{ {
$async = new Api\Asyncservice(); $async = new Api\Asyncservice();
$job_id = empty($this->async_job_id) ? self::PERIOD_ASYNC_ID_PREFIX.$this->id : $this->async_job_id; $job_id = empty($this->async_job_id) ? self::PERIOD_ASYNC_ID_PREFIX.$this->id : $this->async_job_id;