Forward port of import log false error fixes.
This commit is contained in:
parent
c6577851d0
commit
8bd9f14a3f
3 changed files with 80 additions and 9 deletions
|
|
@ -56,6 +56,8 @@
|
|||
http://www.webgui.org/bugs/tracker/matrix-filling-out-no-fields-leads-to-unapprovable-listing
|
||||
- fix: DiskUsage will return -1 if value too large (perlDreamer Consulting, LLC)
|
||||
http://www.webgui.org/bugs/tracker/diskusage-will-return--1-if-value-too-large
|
||||
- fix: Importing a package logs 'Consult your database tables for corruption' errors (perlDreamer Consulting, LLC)
|
||||
http://www.webgui.org/bugs/tracker/importing-a-package-logs-consult-your-database-tables-for-corruption-errors
|
||||
|
||||
7.3.19
|
||||
- Fixed a formatting problem in the workflow editor screen.
|
||||
|
|
|
|||
|
|
@ -81,6 +81,79 @@ sub addMissing {
|
|||
return $ac->render($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 assetDbProperties ( session, assetId, className, revisionDate )
|
||||
|
||||
Class method to return all properties in all tables used by a particular Asset.
|
||||
Returns a hash ref with data from the table.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 assetId
|
||||
|
||||
The assetId of the asset you're creating an object reference for. Must not be blank.
|
||||
|
||||
=head3 className
|
||||
|
||||
By default we'll use whatever class it is called by like WebGUI::Asset::File->new(), so WebGUI::Asset::File would be used.
|
||||
|
||||
=head3 revisionDate
|
||||
|
||||
An epoch date that represents a specific version of an asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub assetDbProperties {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my ($assetId, $className, $revisionDate) = @_;
|
||||
my $sql = "select * from asset";
|
||||
my $where = " where asset.assetId=?";
|
||||
my $placeHolders = [$assetId];
|
||||
foreach my $definition (@{$class->definition($session)}) {
|
||||
$sql .= ",".$definition->{tableName};
|
||||
$where .= " and (asset.assetId=".$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate.")";
|
||||
}
|
||||
return $session->db->quickHashRef($sql.$where, $placeHolders);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 assetExists ( session, assetId, className, revisionDate )
|
||||
|
||||
Class method that checks to see if an asset exists in all the proper tables for
|
||||
the requested asset class. Returns true or false.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 assetId
|
||||
|
||||
The assetId of the asset you're creating an object reference for. Must not be blank.
|
||||
|
||||
=head3 className
|
||||
|
||||
By default we'll use whatever class it is called by like WebGUI::Asset::File->new(), so WebGUI::Asset::File would be used.
|
||||
|
||||
=head3 revisionDate
|
||||
|
||||
An epoch date that represents a specific version of an asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub assetExists {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my ($assetId, $className, $revisionDate) = @_;
|
||||
my $dbProperties = $class->assetDbProperties($session, $assetId, $className, $revisionDate);
|
||||
return exists $dbProperties->{assetId};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canAdd ( session, [userId, groupId] )
|
||||
|
|
@ -1533,13 +1606,7 @@ sub new {
|
|||
if (exists $properties->{assetId}) {
|
||||
# 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 .= ",".$definition->{tableName};
|
||||
$where .= " and (asset.assetId=".$definition->{tableName}.".assetId and ".$definition->{tableName}.".revisionDate=".$revisionDate.")";
|
||||
}
|
||||
$properties = $session->db->quickHashRef($sql.$where);
|
||||
$properties = WebGUI::Asset->assetDbProperties($session, $assetId, $class, $revisionDate);
|
||||
unless (exists $properties->{assetId}) {
|
||||
$session->errorHandler->error("Asset $assetId $class $revisionDate is missing properties. Consult your database tables for corruption. ");
|
||||
return undef;
|
||||
|
|
|
|||
|
|
@ -131,8 +131,10 @@ sub importAssetData {
|
|||
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
|
||||
my $asset;
|
||||
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});
|
||||
##Pending assets are assigned a new version tag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue