From 8c18415c54f53788b3adebd42fbb699e1fbf16b1 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Fri, 13 Aug 2010 13:27:33 -0700 Subject: [PATCH] Stop realtime run on deleted wf instances --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Workflow/Instance.pm | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index cc8db22da..ced412fe2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.9.13 + - fixed #11783: Instances deleted during realtime run 7.9.12 - webgui.org homepage gives 404 (#11778) diff --git a/lib/WebGUI/Workflow/Instance.pm b/lib/WebGUI/Workflow/Instance.pm index 7136b9303..3de0fcae2 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -106,6 +106,10 @@ sub delete { $self->session->db->write("delete from WorkflowInstanceScratch where instanceId=?",[$self->getId]); $self->session->db->deleteRow("WorkflowInstance","instanceId",$self->getId); WebGUI::Workflow::Spectre->new($self->session)->notify("workflow/deleteInstance",$self->getId) unless ($skipNotify); + + # We will need to remember that we were deleted if we get realtime-run + # during start(). + $self->{deleted} = 1; } #------------------------------------------------------------------- @@ -643,7 +647,8 @@ sub start { my $start = time(); my $status = "complete"; $log->info('Trying to execute workflow instance '.$self->getId.' in realtime.'); - while ($status eq "complete" && ($start > time() -10)) { # how much can we run in 10 seconds + # If we got deleted in the middle, we need to stop. This is a hack. + while (!$self->{deleted} && $status eq "complete" && ($start > time() -10)) { # how much can we run in 10 seconds $status = $self->run; $log->info('Completed activity for workflow instance '.$self->getId.' in realtime with return status of '.$status.'.'); }