diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f286cdc61..7e19cea80 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,9 @@ (Diona Kidd, Knowmad Technologies) - rfe: Add menuTitle to folder template (perlDreamer Consulting, LLC) +7.4.19 + - fix: Import Package does nothing when re-importing trashed package + 7.4.18 - fix: Graph draws black triangle covering half the image - fix: upgrade.pl willing to upgrade from versions prior to 7.3.22 diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index 3fe41ce7b..000188706 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -125,18 +125,18 @@ A hash reference containing the exported data. =cut sub importAssetData { - my $self = shift; - my $data = shift; - my $error = $self->session->errorHandler; - my $id = $data->{properties}{assetId}; - my $class = $data->{properties}{className}; - my $version = $data->{properties}{revisionDate}; + my $self = shift; + my $data = shift; + my $error = $self->session->errorHandler; + my $id = $data->{properties}{assetId}; + my $class = $data->{properties}{className}; + my $version = $data->{properties}{revisionDate}; my $asset; - my $assetExists = WebGUI::Asset->assetExists($self->session, $id, $class, $version); - if ($assetExists) { # update an existing revision + my $assetExists = WebGUI::Asset->assetExists($self->session, $id, $class, $version); + if ($assetExists) { # update an existing revision $asset = WebGUI::Asset->new($self->session, $id, $class, $version); - $error->info("Updating an existing revision of asset $id"); - $asset->update($data->{properties}); + $error->info("Updating an existing revision of asset $id"); + $asset->update($data->{properties}); ##Pending assets are assigned a new version tag if ($data->{properties}->{status} eq 'pending') { $self->session->db->write( @@ -144,19 +144,25 @@ sub importAssetData { [WebGUI::VersionTag->getWorking($self->session)->getId, $data->{properties}->{assetId}] ); } - } + } else { - $asset = WebGUI::Asset->new($self->session, $id, $class); - if (defined $asset) { # create a new revision of an existing asset - $error->info("Creating a new revision of asset $id"); - $asset = $asset->addRevision($data->{properties}, $version, {skipAutoCommitWorkflows => 1}); - } + $asset = WebGUI::Asset->new($self->session, $id, $class); + if (defined $asset) { # create a new revision of an existing asset + $error->info("Creating a new revision of asset $id"); + $asset = $asset->addRevision($data->{properties}, $version, {skipAutoCommitWorkflows => 1}); + } else { # add an entirely new asset - $error->info("Adding $id that didn't previously exist."); - $asset = $self->addChild($data->{properties}, $id, $version, {skipAutoCommitWorkflows => 1}); - } - } - return $asset; + $error->info("Adding $id that didn't previously exist."); + $asset = $self->addChild($data->{properties}, $id, $version, {skipAutoCommitWorkflows => 1}); + } + } + + # If the asset is in the trash, re-publish it + if ( $asset->isInTrash ) { + $asset->publish; + } + + return $asset; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index 959d87be6..cae344f8d 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -90,6 +90,18 @@ sub getAssetsInTrash { return \@assets; } +#---------------------------------------------------------------------------- + +=head2 isInTrash ( ) + +Returns true if the asset is in the trash. + +=cut + +sub isInTrash { + my $self = shift; + return $self->get("state") eq "trash"; +} #-------------------------------------------------------------------