Fix Cron issues with CSes. Fixes bug #11284.
This commit is contained in:
parent
cb74591afa
commit
9bb5497aff
4 changed files with 67 additions and 19 deletions
|
|
@ -1,6 +1,7 @@
|
|||
7.8.7
|
||||
- fixed #11278: Wrong test for Template::Toolkit in testEnvironment.pl
|
||||
- fixed #11282: USPS Shipping Driver does not accept ZIP+4
|
||||
- fixed #11284: Collaboration System Cron jobs for email
|
||||
|
||||
7.8.6
|
||||
- fixed #11250: i18n Asset_EMSSubmissionForm::delete created items label help
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ use Getopt::Long;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Workflow::Cron;
|
||||
use WebGUI::Asset::Wobject::Collaboration;
|
||||
|
||||
|
||||
my $toVersion = '7.8.7';
|
||||
|
|
@ -31,6 +33,8 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
clearOrphanedCSMailCronJobs($session);
|
||||
deleteExtraCronJobsForCS($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -44,6 +48,46 @@ finish($session); # this line required
|
|||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub clearOrphanedCSMailCronJobs {
|
||||
my $session = shift;
|
||||
print "\tClear orphaned csworkflow000000000001 Cron Jobs with no CS attached... " unless $quiet;
|
||||
my $crons = WebGUI::Workflow::Cron->getAllTasks($session);
|
||||
##This section of code handles cron jobs created for CS'es where the revision of the
|
||||
##CS with the cron has been deleted.
|
||||
CRON: foreach my $cron (@{ $crons }) {
|
||||
next CRON unless $cron->get('workflowId') eq 'csworkflow000000000001';
|
||||
my $assetId = $cron->get('parameters');
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId);
|
||||
next CRON if $asset;
|
||||
print "\n\t\tDeleting ".$cron->get('title') unless $quiet;
|
||||
$cron->delete;
|
||||
}
|
||||
print "\tDONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub deleteExtraCronJobsForCS {
|
||||
my $session = shift;
|
||||
print "\tGuarantee that each CS has one and only one Cron job. Older jobs will be deleted... " unless $quiet;
|
||||
my $cses = WebGUI::Asset::Wobject::Collaboration->getIsa($session);
|
||||
CS: while( my $cs = $cses->() ) {
|
||||
my @cronIds = $session->db->buildArray('select distinct(getMailCronId) from Collaboration where assetId=?',[$cs->getId]);
|
||||
next CS unless @cronIds > 1;
|
||||
my @oldCronIds = grep { $_ ne $cs->get('getMailCronId') } @cronIds;
|
||||
CRON: foreach my $cronId (@oldCronIds) {
|
||||
my $cron = WebGUI::Workflow::Cron->new($session, $cronId);
|
||||
next CRON unless $cron;
|
||||
print "\n\t\tDeleting ".$cron->get('title') unless $quiet;
|
||||
$cron->delete;
|
||||
}
|
||||
$session->db->write('update Collaboration set getMailCronId=? where assetId=?', [$cs->get('getMailCronId'), $cs->getId]);
|
||||
}
|
||||
print "\tDONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -946,6 +946,16 @@ sub duplicate {
|
|||
my $self = shift;
|
||||
my $newAsset = $self->next::method(@_);
|
||||
$newAsset->createSubscriptionGroup;
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Collaboration");
|
||||
my $newCron = WebGUI::Workflow::Cron->create($self->session, {
|
||||
title=>$self->getTitle." ".$i18n->get("mail"),
|
||||
minuteOfHour=>"*/".($self->get("getMailInterval")/60),
|
||||
className=>(ref $self),
|
||||
methodName=>"new",
|
||||
parameters=>$self->getId,
|
||||
workflowId=>"csworkflow000000000001"
|
||||
});
|
||||
$self->update({getMailCronId=>$newCron->getId});
|
||||
return $newAsset;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,6 @@
|
|||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# XXX I (chrisn) started this file to test the features I added to the
|
||||
# Collaboration / Post system for 7.5, but didn't have the time available to me
|
||||
# to do a full test suite for the Collaboration Wobject. This means that this
|
||||
# test suite is *largely incomplete* and should be finished. What is here *is*
|
||||
# the following:
|
||||
#
|
||||
#
|
||||
# 1. The basic framework for a test suite for the Collaboration Wobject.
|
||||
# Includes setup, cleanup, boilerplate, etc. Basically the really boring,
|
||||
# repetitive parts of the test that you don't want to write yourself.
|
||||
# 2. The tests for the features I've implemented; namely, the groupToEditPost
|
||||
# functionality.
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
|
@ -32,7 +19,7 @@ use WebGUI::Asset::Wobject::Collaboration;
|
|||
use WebGUI::Asset::Post;
|
||||
use WebGUI::Asset::Wobject::Layout;
|
||||
use Data::Dumper;
|
||||
use Test::More tests => 10; # increment this value for each test you create
|
||||
use Test::More tests => 13; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -41,6 +28,7 @@ my $node = WebGUI::Asset->getImportNode($session);
|
|||
|
||||
# grab a named version tag
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($versionTag);
|
||||
$versionTag->set({name => 'Collaboration => groupToEditPost test'});
|
||||
|
||||
# place the collab system under a layout to ensure we're using the inherited groupIdEdit value
|
||||
|
|
@ -55,6 +43,10 @@ my $collab = $layout->addChild({
|
|||
url => 'collab',
|
||||
});
|
||||
|
||||
$versionTag->commit;
|
||||
$collab = $collab->cloneFromDb;
|
||||
ok($session->id->valid($collab->get('getMailCronId')), 'commited CS has a cron job created for it');
|
||||
|
||||
# Test for a sane object type
|
||||
isa_ok($collab, 'WebGUI::Asset::Wobject::Collaboration');
|
||||
|
||||
|
|
@ -99,12 +91,13 @@ is($collab->getRssFeedUrl, '/collab?func=viewRss', 'getRssFeedUrl');
|
|||
is($collab->getRdfFeedUrl, '/collab?func=viewRdf', 'getRdfFeedUrl');
|
||||
is($collab->getAtomFeedUrl, '/collab?func=viewAtom', 'getAtomFeedUrl');
|
||||
|
||||
note "Mail Cron job tests";
|
||||
my $dupedCollab = $collab->duplicate();
|
||||
addToCleanup(WebGUI::VersionTag->new($session, $dupedCollab->get('tagId')));
|
||||
ok($dupedCollab->get('getMailCronId'), 'Duplicated CS has a cron job');
|
||||
isnt($dupedCollab->get('getMailCronId'), $collab->get('getMailCronId'), '... and it is different from its source asset');
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'A whole lot more work to do here');
|
||||
}
|
||||
|
||||
END {
|
||||
# Clean up after thyself
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue