From 07582c34d62a50c7688b0990c198d5974109c6c4 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 20 Jun 2007 04:43:11 +0000 Subject: [PATCH] Forward port of Workflow Activity sequencing bug. create uses count, but delete did not reorder the existing activities. This would allow duplicate sequenceNumbers in the db. The upgrade script will resequence and fix all activities in all workflows. --- docs/changelog/7.x.x.txt | 2 ++ docs/upgrades/upgrade_7.3.18-7.3.19.pl | 20 +++++++++++++++++++- lib/WebGUI/Workflow.pm | 5 ++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ac5147624..884378146 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -52,6 +52,8 @@ - fix: Fixed a typo in the Article with attachments template (perlDreamer Consulting, LLC) - fix: Uploaded File Sizes Wrong (perlDreamer Consulting, LLC) http://www.webgui.org/bugs/tracker/uploaded-file-sizes-wrong#8ao9yNQrxFyJNTUaU7ARPA + - fix: Activity Sequence Numbers Incorrect when Editing Workflows (perlDreamer Consulting, LLC) + http://www.webgui.org/bugs/tracker/activity-sequence-numbers-incorrect-when-editing-workflows#YRH7TYSWFkEUSPVDNN6zKQ 7.3.18 diff --git a/docs/upgrades/upgrade_7.3.18-7.3.19.pl b/docs/upgrades/upgrade_7.3.18-7.3.19.pl index 8b0de524e..32f1b66e4 100644 --- a/docs/upgrades/upgrade_7.3.18-7.3.19.pl +++ b/docs/upgrades/upgrade_7.3.18-7.3.19.pl @@ -13,6 +13,7 @@ use strict; use Getopt::Long; use WebGUI::Session; use WebGUI::Asset; +use WebGUI::Workflow; my $toVersion = "7.3.19"; # make this match what version you're going to @@ -23,6 +24,7 @@ my $session = start(); # this line required # upgrade functions go here fixAssetSizes($session); +resequenceWorkflowActivities($session); finish($session); # this line required @@ -35,9 +37,25 @@ sub fixAssetSizes { foreach my $fileAsset ( @{ $root->getLineage(["self","descendants"],{returnObjects=>1,includeOnlyClasses=>['WebGUI::Asset::File','WebGUI::Asset::Image']}) } ) { $fileAsset->setSize(); } - # and here's our code } +#------------------------------------------------- +sub resequenceWorkflowActivities { + my $session = shift; + print "\tFix sequencing problems in Workflow Activities. This will take a while.\n" unless ($quiet); + my $workflows = WebGUI::Workflow->getList($session); + use Data::Dumper; + $session->errorHandler->warn(Dumper $workflows); + my ($workflowId, $title); + while ( ($workflowId, $title) = each %{ $workflows } ) { + $session->errorHandler->warn($workflowId . ':' . $title); + my $workflow = WebGUI::Workflow->new($session, $workflowId); + next unless defined $workflow; + $workflow->reorderActivities; + } +} + + # ---- DO NOT EDIT BELOW THIS LINE ---- diff --git a/lib/WebGUI/Workflow.pm b/lib/WebGUI/Workflow.pm index b70a47134..f448fda02 100644 --- a/lib/WebGUI/Workflow.pm +++ b/lib/WebGUI/Workflow.pm @@ -133,7 +133,10 @@ sub deleteActivity { my $self = shift; my $activityId = shift; my $activity = $self->getActivity($activityId); - $activity->delete if ($activity); + if ($activity) { + $activity->delete; + $self->reorderActivities; + } } #-------------------------------------------------------------------