Fix problems with the Story Archive leaking version tags when it is not committed. Fixes bug #11678

This commit is contained in:
Colin Kuskie 2010-06-23 14:12:42 -07:00
parent 321f165147
commit b7ba9f2118
5 changed files with 31 additions and 6 deletions

View file

@ -8,6 +8,8 @@
- fixed #11626: Duplicate messages from Collab Systems - fixed #11626: Duplicate messages from Collab Systems
- fixed #11667: Shop: unable to remove item from Cart - fixed #11667: Shop: unable to remove item from Cart
- fixed #11550: Pending assets in the clipboard or trash are not visible from the approval screen - fixed #11550: Pending assets in the clipboard or trash are not visible from the approval screen
- fixed #11678: Story Archive leaks version tags
7.9.7 7.9.7
- added #11571: Allow return from photo edit view to gallery edit view - added #11571: Allow return from photo edit view to gallery edit view

View file

@ -319,9 +319,14 @@ sub getFolder {
##For a fully automatic commit, save the current tag, create a new one ##For a fully automatic commit, save the current tag, create a new one
##with the commit without approval workflow, commit it, then restore ##with the commit without approval workflow, commit it, then restore
##the original if it exists ##the original if it exists
my $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate'); my ($oldVersionTag, $newVersionTag);
my $newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', }); $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
$newVersionTag->setWorking;
if ($self->hasBeenCommitted) {
$newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
$newVersionTag->setWorking;
$newVersionTag->set({ name => 'Adding folder '. $folderName. ' to archive '. $self->getUrl});
}
##Call SUPER because my addChild calls getFolder ##Call SUPER because my addChild calls getFolder
$folder = $self->SUPER::addChild({ $folder = $self->SUPER::addChild({
@ -332,7 +337,7 @@ sub getFolder {
isHidden => 1, isHidden => 1,
styleTemplateId => $self->get('styleTemplateId'), styleTemplateId => $self->get('styleTemplateId'),
}); });
$newVersionTag->commit(); $newVersionTag->commit() if $newVersionTag;
##Restore the old one, if it exists ##Restore the old one, if it exists
$oldVersionTag->setWorking() if $oldVersionTag; $oldVersionTag->setWorking() if $oldVersionTag;

View file

@ -70,6 +70,9 @@ my $topic = $defaultNode->addChild({
my $archiveTag = WebGUI::VersionTag->getWorking($session); my $archiveTag = WebGUI::VersionTag->getWorking($session);
$archiveTag->commit; $archiveTag->commit;
WebGUI::Test->addToCleanup($archiveTag); WebGUI::Test->addToCleanup($archiveTag);
foreach my $asset ($archive, $topic) {
$asset = $asset->cloneFromDb;
}
my $storage1 = WebGUI::Storage->create($session); my $storage1 = WebGUI::Storage->create($session);
my $storage2 = WebGUI::Storage->create($session); my $storage2 = WebGUI::Storage->create($session);

View file

@ -63,7 +63,7 @@ $canPostMaker->prepare({
fail => [1, $reader ], fail => [1, $reader ],
}); });
my $tests = 50 my $tests = 51
+ $canPostMaker->plan + $canPostMaker->plan
; ;
plan tests => 1 plan tests => 1
@ -95,6 +95,7 @@ $archive = $home->addChild({
$versionTag = WebGUI::VersionTag->getWorking($session); $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit; $versionTag->commit;
WebGUI::Test->addToCleanup($versionTag); WebGUI::Test->addToCleanup($versionTag);
$archive = $archive->cloneFromDb;
isa_ok($archive, 'WebGUI::Asset::Wobject::StoryArchive', 'created StoryArchive'); isa_ok($archive, 'WebGUI::Asset::Wobject::StoryArchive', 'created StoryArchive');
@ -152,6 +153,17 @@ undef $sameFolder;
$todayFolder->purge; $todayFolder->purge;
is($archive->getChildCount, 0, 'leaving with an empty archive'); is($archive->getChildCount, 0, 'leaving with an empty archive');
{
my $archive2 = $home->addChild({
className => 'WebGUI::Asset::Wobject::StoryArchive',
title => 'Uncommitted',
url => 'uncommitted_archive',
});
my $guard = WebGUI::Test->cleanupGuard($archive2);
my $new_folder = $archive2->getFolder;
is $archive2->get('tagId'), $new_folder->get('tagId'), 'folder added to uncommitted archive uses the same version tag';
}
################################################################ ################################################################
# #
# addChild # addChild

View file

@ -62,7 +62,10 @@ $creationDateSth->execute([$weekAgo, $weekStory->getId]);
my $versionTag = WebGUI::VersionTag->getWorking($session); my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit; $versionTag->commit;
addToCleanup($versionTag); WebGUI::Test->addToCleanup($versionTag);
foreach my $asset ($archive1, $archive2) {
$asset = $asset->cloneFromDb;
}
my $workflow = WebGUI::Workflow->create($session, my $workflow = WebGUI::Workflow->create($session,
{ {