diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b96d01bd1..5d53e4566 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.9.7 - fixed #11596: Calendar: all day events leaking + - fixed #11604: scheduled workflows getting deleted 7.9.6 - new checkbox in the asset manager for clearing the package flag on import diff --git a/docs/gotcha.txt b/docs/gotcha.txt index f4c25d6fe..72182487c 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -7,6 +7,13 @@ upgrading from one version to the next, or even between multiple versions. Be sure to heed the warnings contained herein as they will save you many hours of grief. +7.9.7 +-------------------------------------------------------------------- + * Due to a bug introduced in 7.9.3, Scheduler tasks may have been deleted + from your site. The 7.9.7 upgrade will restore all default tasks, and tasks + for handling email from Collaboration Systems, but you should check any Scheduler + tasks that you have created. + 7.9.6 -------------------------------------------------------------------- * The javascript check for email addresses has been removed. diff --git a/docs/upgrades/upgrade_7.9.6-7.9.7.pl b/docs/upgrades/upgrade_7.9.6-7.9.7.pl index e2583cb92..a87756f37 100644 --- a/docs/upgrades/upgrade_7.9.6-7.9.7.pl +++ b/docs/upgrades/upgrade_7.9.6-7.9.7.pl @@ -22,6 +22,10 @@ use Getopt::Long; use WebGUI::Session; use WebGUI::Storage; use WebGUI::Asset; +use WebGUI::Asset::Wobject::Collaboration; +use WebGUI::Exception; +use WebGUI::Workflow::Cron; +use WebGUI::Utility qw/isIn/; my $toVersion = '7.9.7'; @@ -31,6 +35,8 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +restoreDefaultCronJobs($session); +restoreCsCronJobs($session); finish($session); # this line required @@ -44,6 +50,101 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- +# Describe what our function does +sub restoreDefaultCronJobs { + my $session = shift; + # and here's our code + print "\tRestore missing default cron jobs that may have been deleted... " unless $quiet; + my $tasks = WebGUI::Workflow::Cron->getAllTasks($session); + my @taskIds = map { $_->getId } @{ $tasks }; + if (! isIn('pbcron0000000000000001', @taskIds)) { + print "\n\t\tRestoring Daily Maintenance Task... " unless $quiet; + WebGUI::Workflow::Cron->create($session, { + title => "Daily Maintenance", dayOfMonth => '*', + enabled => 1, monthOfYear => '*', + runOnce => 0, dayOfWeek => '*', + minuteOfHour => 30, workflowId => 'pbworkflow000000000001', + hourOfDay => 23, priority => 3, + }, + 'pbcron0000000000000001'); + } + if (! isIn('pbcron0000000000000002', @taskIds)) { + print "\n\t\tRestoring Weekly Maintenance Task... " unless $quiet; + WebGUI::Workflow::Cron->create($session, { + title => "Weekly Maintenance", dayOfMonth => '*', + enabled => 1, monthOfYear => '*', + runOnce => 0, dayOfWeek => '0', + minuteOfHour => 30, workflowId => 'pbworkflow000000000002', + hourOfDay => 1, priority => 3, + }, + 'pbcron0000000000000002'); + } + if (! isIn('pbcron0000000000000003', @taskIds)) { + print "\n\t\tRestoring Hourly Maintenance Task... " unless $quiet; + WebGUI::Workflow::Cron->create($session, { + title => "Hourly Maintenance", dayOfMonth => '*', + enabled => 1, monthOfYear => '*', + runOnce => 0, dayOfWeek => '*', + minuteOfHour => 15, workflowId => 'pbworkflow000000000004', + hourOfDay => '*', priority => 3, + }, + 'pbcron0000000000000003'); + } + if (! isIn('pbcron0000000000000004', @taskIds)) { + print "\n\t\tRestoring Email Delivery Task... " unless $quiet; + WebGUI::Workflow::Cron->create($session, { + title => "Send Queued Email Messages Every 5 Minutes", + dayOfMonth => '*', + enabled => 1, monthOfYear => '*', + runOnce => 0, dayOfWeek => '*', + minuteOfHour => '*/5', workflowId => 'pbworkflow000000000007', + hourOfDay => '*', priority => 3, + }, + 'pbcron0000000000000004'); + } + print "DONE!\n" unless $quiet; +} + +#---------------------------------------------------------------------------- +# Describe what our function does +sub restoreCsCronJobs { + my $session = shift; + print "\tRestore missing Collaboration System cron jobs that may have been deleted... " unless $quiet; + my $i18n = WebGUI::International->new($session, "Asset_Collaboration"); + my $getCs = WebGUI::Asset::Wobject::Collaboration->getIsa($session); + CS: while (1) { + my $cs = eval { $getCs->(); }; + if (my $e = Exception::Class->caught()) { + $session->log->error($@); + next CS; + } + last CS unless $cs; + ##Do something useful with $product + my $cron = undef; + if ($cs->get("getMailCronId")) { + $cron = WebGUI::Workflow::Cron->new($session, $cs->get("getMailCronId")); + } + next CS if $cron; + $cron = WebGUI::Workflow::Cron->create($session, { + title => $cs->getTitle." ".$i18n->get("mail"), + minuteOfHour => "*/".($cs->get("getMailInterval")/60), + className => (ref $cs), + methodName => "new", + parameters => $cs->getId, + workflowId => "csworkflow000000000001" + }); + $cs->update({getMailCronId=>$cron->getId}); + if ($cs->get("getMail")) { + $cron->set({enabled=>1,title=>$cs->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($cs->get("getMailInterval")/60)}); + } else { + $cron->set({enabled=>0,title=>$cs->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($cs->get("getMailInterval")/60)}); + } + + } + print "DONE!\n" unless $quiet; +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/lib/WebGUI/Operation/Cron.pm b/lib/WebGUI/Operation/Cron.pm index d32c9fe79..ccfa81e49 100644 --- a/lib/WebGUI/Operation/Cron.pm +++ b/lib/WebGUI/Operation/Cron.pm @@ -308,7 +308,6 @@ sub www_runCronJob { # Run the instance my $error = $instance->start( 1 ); if ($error) { - $task->delete(1); return "error"; } $task->delete( 1 ) if ( $task->get("runOnce") );