diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 26e02e93c..e34eb34e2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -8,6 +8,8 @@ - fixed #11626: Duplicate messages from Collab Systems - 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 #11678: Story Archive leaks version tags + 7.9.7 - added #11571: Allow return from photo edit view to gallery edit view diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index 4e966d5d6..c860f24e4 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -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({ @@ -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; diff --git a/t/Asset/Story.t b/t/Asset/Story.t index b480a35b8..9acf123b8 100644 --- a/t/Asset/Story.t +++ b/t/Asset/Story.t @@ -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); diff --git a/t/Asset/Wobject/StoryArchive.t b/t/Asset/Wobject/StoryArchive.t index bd69eec1e..2268768e6 100644 --- a/t/Asset/Wobject/StoryArchive.t +++ b/t/Asset/Wobject/StoryArchive.t @@ -63,7 +63,7 @@ $canPostMaker->prepare({ fail => [1, $reader ], }); -my $tests = 50 +my $tests = 51 + $canPostMaker->plan ; plan tests => 1 @@ -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'); @@ -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 diff --git a/t/Workflow/Activity/ArchiveOldStories.t b/t/Workflow/Activity/ArchiveOldStories.t index 023a330b6..bdc7acd73 100644 --- a/t/Workflow/Activity/ArchiveOldStories.t +++ b/t/Workflow/Activity/ArchiveOldStories.t @@ -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, {