Skip to content

Commit

Permalink
FIX Don't remove jobs when processing via publish job
Browse files Browse the repository at this point in the history
WorkflowPublishTargetJob::process() triggers a onBeforeWrite() which in turn can lead to job descriptors being deleted while still being used.
Don't delete completed jobs when setting up new ones.
  • Loading branch information
wilr authored and Michal Kleiner committed Jun 29, 2023
1 parent 271b6b5 commit 8bc9a24
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Extensions/WorkflowEmbargoExpiryExtension.php
Expand Up @@ -182,7 +182,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;
Expand All @@ -195,7 +195,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;
Expand Down Expand Up @@ -299,6 +299,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();
Expand Down

0 comments on commit 8bc9a24

Please sign in to comment.