From 890a94d3d5ea7f0ac7a12c7bf56d00f2f9d8198f 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 | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) 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 a0df11343..83a2c0842 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -106,7 +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); - undef $self; + + # We will need to remember that we were deleted if we get realtime-run + # during start(). + $self->{deleted} = 1; } #------------------------------------------------------------------- @@ -645,7 +648,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.'.'); }