diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 7e19cea80..bd5fd802e 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,7 @@ 7.4.19 - fix: Import Package does nothing when re-importing trashed package + - fix: CS Posts get re-ordered when copy/paste 7.4.18 - fix: Graph draws black triangle covering half the image diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 449db946d..c4282b098 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -76,14 +76,21 @@ Assets that normally autocommit their workflows (like CS Posts, and Wiki Pages) =cut sub duplicate { - my $self = shift; - my $options = shift; - my $newAsset = $self->getParent->addChild($self->get, undef, undef, {skipAutoCommitWorkflows=>$options->{skipAutoCommitWorkflows}}); - my $sth = $self->session->db->read("select * from metaData_values where assetId = ?", [$self->getId]); - while (my $h = $sth->hashRef) { - $self->session->db->write("insert into metaData_values (fieldId, assetId, value) values (?, ?, ?)", [$h->{fieldId}, $newAsset->getId, $h->{value}]); - } - return $newAsset; + my $self = shift; + my $options = shift; + my $newAsset + = $self->getParent->addChild( $self->get, undef, $self->get("revisionDate"), { skipAutoCommitWorkflows => $options->{skipAutoCommitWorkflows} } ); + + # Duplicate metadata fields + my $sth = $self->session->db->read( + "select * from metaData_values where assetId = ?", + [$self->getId] + ); + while (my $h = $sth->hashRef) { + $self->session->db->write("insert into metaData_values (fieldId, assetId, value) values (?, ?, ?)", [$h->{fieldId}, $newAsset->getId, $h->{value}]); + } + + return $newAsset; } diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index e2110daf5..06a7bd940 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -63,11 +63,11 @@ If this is set to 1 assets that normally autocommit their workflows (like CS Pos =cut sub addChild { - my $self = shift; - my $properties = shift; - my $id = shift || $self->session->id->generate(); - my $now = shift || $self->session->datetime->time(); - my $options = shift; + my $self = shift; + my $properties = shift; + my $id = shift || $self->session->id->generate(); + my $now = shift || $self->session->datetime->time(); + my $options = shift; # Check if it is possible to add a child to this asset. If not add it as a sibling of this asset. if (length($self->get("lineage")) >= 252) { diff --git a/t/Asset/AssetClipboard.t b/t/Asset/AssetClipboard.t index 36d78331b..2905a2893 100644 --- a/t/Asset/AssetClipboard.t +++ b/t/Asset/AssetClipboard.t @@ -22,7 +22,7 @@ use WebGUI::Asset; use WebGUI::VersionTag; use Test::More; # increment this value for each test you create -plan tests => 5; +plan tests => 6; my $session = WebGUI::Test->session; $session->user({userId => 3}); @@ -38,7 +38,8 @@ my $snippet = $root->addChild({ snippet => 'A snippet of text', }); -my $snippetAssetId = $snippet->getId; +my $snippetAssetId = $snippet->getId; +my $snippetRevisionDate = $snippet->get("revisionDate"); $versionTag->commit; @@ -48,6 +49,11 @@ my $duplicatedSnippet = $snippet->duplicate; is($duplicatedSnippet->get('title'), 'snippet', 'duplicated snippet has correct title'); isnt($duplicatedSnippet->getId, $snippetAssetId, 'duplicated snippet does not have same assetId as original'); +is( + $duplicatedSnippet->get("revisionDate"), + $snippetRevisionDate, + 'duplicated snippet has the same revision date', +); is($snippet->getId, $snippetAssetId, 'original snippet has correct id'); is($snippet->getParent->getId, $root->getId, 'original snippet is a child of root');