diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 7c415cc96..2fe11ad49 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,7 @@ - fixed #11297: YUI Rich Editor fails to load when editing Survey in 7.7.27 - fixed #11306: Survey i18n: Loading.... - fixed #11307: Survey i18n #2 + - fixed #11295: asset addChild failure when parent is not committed 7.8.7 - fixed #11278: Wrong test for Template::Toolkit in testEnvironment.pl diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index 49dce78a0..074c9a95d 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -92,7 +92,7 @@ sub addRevision { my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows}); - my $workingTag; + my ($workingTag, $oldWorking); if ( $autoCommitId ) { $workingTag = WebGUI::VersionTag->create( $self->session, { @@ -109,7 +109,9 @@ sub addRevision { $workingTag = WebGUI::VersionTag->getWorking( $self->session ); } else { + my $oldWorking = WebGUI::VersionTag->getWorking($self->session, 'noCreate'); $workingTag = WebGUI::VersionTag->new( $self->session, $parentAsset->get('tagId') ); + $workingTag->setWorking(); } } @@ -163,6 +165,7 @@ sub addRevision { $newVersion->setVersionLock; $newVersion->update(\%mergedProperties); $newVersion->setAutoCommitTag($workingTag) if (defined $autoCommitId); + $oldWorking->setWorking if $oldWorking; return $newVersion; } diff --git a/t/Asset/AssetLineage.t b/t/Asset/AssetLineage.t index f03192212..07f2bb999 100644 --- a/t/Asset/AssetLineage.t +++ b/t/Asset/AssetLineage.t @@ -17,7 +17,7 @@ use WebGUI::Session; use WebGUI::User; use WebGUI::Asset; -use Test::More tests => 92; # increment this value for each test you create +use Test::More tests => 93; # increment this value for each test you create use Test::Deep; # Test the methods in WebGUI::AssetLineage @@ -526,6 +526,26 @@ $vTag2->commit; is($deepAsset[41]->getParent->getId, $deepAsset[40]->getId, 'addChild will not create an asset with a lineage deeper than 42 levels'); like($WebGUI::Test::logger_warns, qr/Adding it as a sibling instead/, 'addChild logged a warning about deep assets'); +{ + my $tag = WebGUI::VersionTag->getWorking($session); + addToCleanup($tag); + my $uncommittedParent = $root->addChild({ + className => "WebGUI::Asset::Wobject::Layout", + groupIdView => 7, + ownerUserId => 3, + title => "Uncommitted Parent", + }); + $tag->leaveTag; + my $parent = WebGUI::Asset->newPending($session, $uncommittedParent->getId); + my $floater = $parent->addChild({ + className => "WebGUI::Asset::Snippet", + groupIdView => 7, + ownerUserId => 3, #For coverage on addChild properties + title => "Child of uncommitted parent", + }); + is $parent->get('tagId'), $floater->get('tagId'), 'addChild: with uncommitted parent, adds child and puts it into the same tag as the parent'; +} + TODO: { local $TODO = "Tests to make later"; ok(0, 'addChild');