diff --git a/src/Extensions/WorkflowEmbargoExpiryExtension.php b/src/Extensions/WorkflowEmbargoExpiryExtension.php index 4b5a80ca..f0d67443 100644 --- a/src/Extensions/WorkflowEmbargoExpiryExtension.php +++ b/src/Extensions/WorkflowEmbargoExpiryExtension.php @@ -176,7 +176,7 @@ public function updateCMSFields(FieldList $fields) public function clearPublishJob() { $job = $this->owner->PublishJob(); - if ($job && $job->exists()) { + if ($job && $job->exists() && !$job->JobFinished) { $job->delete(); } $this->owner->PublishJobID = 0; @@ -189,7 +189,7 @@ public function clearUnPublishJob() { // Cancel any in-progress unpublish job $job = $this->owner->UnPublishJob(); - if ($job && $job->exists()) { + if ($job && $job->exists() && !$job->JobFinished) { $job->delete(); } $this->owner->UnPublishJobID = 0; @@ -293,6 +293,10 @@ public function onBeforeWrite() if (!$this->owner->ID) { return; } + + if ($this->owner->hasMethod('isPublishJobRunning') && $this->owner->isPublishJobRunning()) { + return; + } // Check requested dates of publish / unpublish, and whether the page should have already been unpublished $now = DBDatetime::now()->getTimestamp();