Skip to content

Commit

Permalink
Fix problems with the Story Archive leaking version tags when it is n…
Browse files Browse the repository at this point in the history
…ot committed. Fixes bug #11678
  • Loading branch information
perlDreamer committed Jun 23, 2010
1 parent 8f04e12 commit fcaf36a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/7.x.x.txt
Expand Up @@ -14,6 +14,8 @@
- fixed #11646: Post and Thread Last Post
- fixed #11626: Duplicate messages from Collab Systems
- fixed #11550: Pending assets in the clipboard or trash are not visible from the approval screen
- fixed #11678: Story Archive leaks version tags


7.8.21
- fixed #11597: manageTrash and newlines
Expand Down
13 changes: 9 additions & 4 deletions lib/WebGUI/Asset/Wobject/StoryArchive.pm
Expand Up @@ -319,9 +319,14 @@ sub getFolder {
##For a fully automatic commit, save the current tag, create a new one
##with the commit without approval workflow, commit it, then restore
##the original if it exists
my $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
my $newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
$newVersionTag->setWorking;
my ($oldVersionTag, $newVersionTag);
$oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');

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
$folder = $self->SUPER::addChild({
Expand All @@ -332,7 +337,7 @@ sub getFolder {
isHidden => 1,
styleTemplateId => $self->get('styleTemplateId'),
});
$newVersionTag->commit();
$newVersionTag->commit() if $newVersionTag;
##Restore the old one, if it exists
$oldVersionTag->setWorking() if $oldVersionTag;

Expand Down
3 changes: 3 additions & 0 deletions t/Asset/Story.t
Expand Up @@ -70,6 +70,9 @@ my $topic = $defaultNode->addChild({
my $archiveTag = WebGUI::VersionTag->getWorking($session);
$archiveTag->commit;
WebGUI::Test->addToCleanup($archiveTag);
foreach my $asset ($archive, $topic) {
$asset = $asset->cloneFromDb;
}

my $storage1 = WebGUI::Storage->create($session);
my $storage2 = WebGUI::Storage->create($session);
Expand Down
14 changes: 13 additions & 1 deletion t/Asset/Wobject/StoryArchive.t
Expand Up @@ -63,7 +63,7 @@ $canPostMaker->prepare({
fail => [1, $reader ],
});

my $tests = 50
my $tests = 51
+ $canPostMaker->plan
;
plan tests => 1
Expand Down Expand Up @@ -95,6 +95,7 @@ $archive = $home->addChild({
$versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
WebGUI::Test->addToCleanup($versionTag);
$archive = $archive->cloneFromDb;

isa_ok($archive, 'WebGUI::Asset::Wobject::StoryArchive', 'created StoryArchive');

Expand Down Expand Up @@ -152,6 +153,17 @@ undef $sameFolder;
$todayFolder->purge;
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
Expand Down
5 changes: 4 additions & 1 deletion t/Workflow/Activity/ArchiveOldStories.t
Expand Up @@ -62,7 +62,10 @@ $creationDateSth->execute([$weekAgo, $weekStory->getId]);

my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
addToCleanup($versionTag);
WebGUI::Test->addToCleanup($versionTag);
foreach my $asset ($archive1, $archive2) {
$asset = $asset->cloneFromDb;
}

my $workflow = WebGUI::Workflow->create($session,
{
Expand Down

0 comments on commit fcaf36a

Please sign in to comment.