diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 5e56c9114..3be57f347 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -44,6 +44,9 @@ - fix: PM resource search popup has no scrollbars - fix: Matrix listings create CS assets with wrong permissions - fix: HttpProxy not requiring Apache2::Upload correctly + - Fixed a bug that could cause package imports to fail if they included + updated revisions of existing assets. This fix may also prevent other + revisionDate related errors, though none are known at this time. 7.1.2 - Fixed a bug where logging in/out would cause a blank page display. diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 5eba55465..58bbc152a 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1459,12 +1459,12 @@ sub new { # got properties from cache } else { my $sql = "select * from asset"; + my $where = " where asset.assetId=".$session->db->quote($assetId); foreach my $definition (@{$class->definition($session)}) { - $sql .= " left join ".$definition->{tableName}." on asset.assetId=" - .$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate; + $sql .= ",".$definition->{tableName}; + $where .= " and (asset.assetId=".$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate.")"; } - $sql .= " where asset.assetId=".$session->db->quote($assetId); - $properties = $session->db->quickHashRef($sql); + $properties = $session->db->quickHashRef($sql.$where); return undef unless (exists $properties->{assetId}); $cache->set($properties,60*60*24); } diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index 970f238c7..7c789ceee 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -127,17 +127,21 @@ A hash reference containing the exported data. 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 $asset = WebGUI::Asset->new($self->session, $id, $class, $version); if (defined $asset) { # update an existing revision + $error->info("Updating an existing revision of asset $id"); $asset->update($data->{properties}); } 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); } else { # add an entirely new asset + $error->info("Adding $id that didn't previously exist."); $asset = $self->addChild($data->{properties}, $id, $version); } } @@ -161,13 +165,17 @@ sub importPackage { my $storage = shift; my $decompressed = $storage->untar($storage->getFiles->[0]); my %assets = (); + my $error = $self->session->errorHandler; + $error->info("Importing package."); foreach my $file (sort(@{$decompressed->getFiles})) { next unless ($decompressed->getFileExtension($file) eq "json"); + $error->info("Found data file $file"); my $data = eval{JSON::jsonToObj($decompressed->getFileContentsAsScalar($file))}; if ($@ || $data->{properties}{assetId} eq "" || $data->{properties}{className} eq "" || $data->{properties}{revisionDate} eq "") { - $self->session->errorHandler->warn("package corruption: ".$@) if ($@); + $error->error("package corruption: ".$@) if ($@); return "corrupt"; } + $error->info("Data file $file is valid and represents asset ".$data->{properties}{assetId}); foreach my $storageId (@{$data->{storage}}) { my $assetStorage = WebGUI::Storage->get($self->session, $storageId); $decompressed->untar($storageId.".storage", $assetStorage);