From be42bb08563f878ebd318fdc2a3ea148dc400cdf Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 8 Feb 2009 21:20:32 +0000 Subject: [PATCH] - Added a switch to allow the use of non-WebGUI objects with the Workflow engine. --- docs/changelog/7.x.x.txt | 2 ++ docs/upgrades/upgrade_7.6.10-7.6.11.pl | 14 +++++++------- lib/WebGUI/Workflow/Instance.pm | 13 +++++++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 80ec92dd5..d8be1e870 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,6 @@ 7.6.11 + - Added a switch to allow the use of non-WebGUI objects with the Workflow + engine. - fixed #9579: initialize keyword field because get fills it in now due to a recent code change - fixed #9596: caching now takes into account the correct parameter for pagination - fixed #9596: Articles now use a semi-unique pagination variable based on asset id diff --git a/docs/upgrades/upgrade_7.6.10-7.6.11.pl b/docs/upgrades/upgrade_7.6.10-7.6.11.pl index b74d649d9..33190c38c 100644 --- a/docs/upgrades/upgrade_7.6.10-7.6.11.pl +++ b/docs/upgrades/upgrade_7.6.10-7.6.11.pl @@ -34,19 +34,19 @@ hideGalleryAlbums($session); removeBrokenWorkflowInstances($session); undotBinaryExtensions($session); removeProcessRecurringPaymentsFromConfig($session); +noSessionSwitch($session); fixDottedAssetIds($session); ##This one should run last finish($session); # this line required #---------------------------------------------------------------------------- -# Describe what our function does -#sub exampleFunction { -# my $session = shift; -# print "\tWe're doing some stuff here that you should know about... " unless $quiet; -# # and here's our code -# print "DONE!\n" unless $quiet; -#} +sub noSessionSwitch { + my $session = shift; + print "\tAdding noSession switch to Workflow Instances..." unless $quiet; + $session->db->write("alter table WorkflowInstance add column noSession boolean not null default 0"); + print "DONE!\n" unless $quiet; +} #---------------------------------------------------------------------------- sub removeProcessRecurringPaymentsFromConfig { diff --git a/lib/WebGUI/Workflow/Instance.pm b/lib/WebGUI/Workflow/Instance.pm index 57d99e5b9..71862a2ad 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -343,11 +343,15 @@ sub run { $self->session->errorHandler->info("Running workflow activity ".$activity->getId.", which is a ".(ref $activity).", for instance ".$self->getId."."); my $class = $self->get("className"); my $method = $self->get("methodName"); - my $params = $self->get("parameters"); my $status = ""; my $object = undef; + my @params; + unless ($self->get('noSession')) { + push @params, $self->session; + } + push @params, $self->get("parameters"); if ($class && $method) { - $object = eval { WebGUI::Pluggable::instanciate($class, $method, [$self->session, $params]) }; + $object = eval { WebGUI::Pluggable::instanciate($class, $method, \@params) }; if ($@) { $self->session->errorHandler->error( q{Error on workflow instance '} . $self->getId . q{': }. $@ @@ -434,6 +438,10 @@ be constructed unless both className and methodName are true. A hashref of parameters to be passed into the constructor for className. Note that the system will always pass in the session as the first argument. +=head4 noSession + +Normally a reference to the session is the first property passed into methodName(), and then the parameters are passed in. If you're using an object that doesn't need/want a WebGUI::Session object then set noSession to 1. Defaults to 0. + =head4 currentActivityId The unique id of the activity in the workflow that needs to be executed next. If blank, it will execute the first activity in the workflow. @@ -451,6 +459,7 @@ A boolean, that if set to 1 will not inform Spectre of the change in settings. sub set { my ($self, $properties, $skipNotify) = @_; $self->{_data}{lastUpdate} = time(); + $self->{_data}{noSession} = (exists $properties->{noSession}) ? $properties->{noSession} : $self->{_data}{noSession}; $self->{_data}{priority} = $properties->{priority} || $self->{_data}{priority} || 2; $self->{_data}{lastStatus} = $properties->{lastStatus} || $self->{_data}{lastStatus}; $self->{_data}{workflowId} = $properties->{workflowId} || $self->{_data}{workflowId};