cleaning up Asset->update checking assetData
This commit is contained in:
parent
3ab206ad48
commit
0efe1fabec
1 changed files with 9 additions and 13 deletions
|
|
@ -1981,10 +1981,13 @@ sub update {
|
||||||
# check the definition of all properties against what was given to us
|
# check the definition of all properties against what was given to us
|
||||||
|
|
||||||
# get a DB object for the two conditionals below, and the description
|
# get a DB object for the two conditionals below, and the description
|
||||||
my $db = $self->session->db;
|
my %assetDataFields;
|
||||||
my $assetDataDescription = $db->buildHashRef('describe assetData');
|
my $sth = $self->session->db->read('DESCRIBE `assetData`');
|
||||||
|
while (my ($col) = $sth->array) {
|
||||||
|
$assetDataFields{$col} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $definition (reverse @{$self->definition($self->session)}) {
|
foreach my $definition (reverse @{$self->definition($self->session)}) {
|
||||||
my %setPairs = ();
|
my %setPairs = ();
|
||||||
|
|
||||||
# deal with all the properties in this part of the definition
|
# deal with all the properties in this part of the definition
|
||||||
|
|
@ -1999,19 +2002,13 @@ sub update {
|
||||||
# if this is the new-to-7.5 isExportable field, check if the
|
# if this is the new-to-7.5 isExportable field, check if the
|
||||||
# database field for it exists. if not, setting it will break, so
|
# database field for it exists. if not, setting it will break, so
|
||||||
# skip it. this facilitates updating from previous versions.
|
# skip it. this facilitates updating from previous versions.
|
||||||
if($property eq 'isExportable') {
|
if ($definition->{tableName} eq 'assetData' && !exists $assetDataFields{$property}) {
|
||||||
unless(grep { $_ =~ /^isExportable/ } keys %{$assetDataDescription}) {
|
next;
|
||||||
next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# similarly, if this is the new-to-7.5 inheritUrlFromParent field,
|
# similarly, if this is the new-to-7.5 inheritUrlFromParent field,
|
||||||
# do the same.
|
# do the same.
|
||||||
elsif($property eq 'inheritUrlFromParent') {
|
if($property eq 'inheritUrlFromParent') {
|
||||||
unless(grep { $_ =~ /^inheritUrlFromParent/ } keys %{$assetDataDescription}) {
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
next unless $properties->{inheritUrlFromParent} == 1;
|
next unless $properties->{inheritUrlFromParent} == 1;
|
||||||
|
|
||||||
# if we're still here, we have the property in the DB. so process it.
|
# if we're still here, we have the property in the DB. so process it.
|
||||||
|
|
@ -2044,7 +2041,6 @@ sub update {
|
||||||
|
|
||||||
# use the update value
|
# use the update value
|
||||||
my $value = $properties->{$property};
|
my $value = $properties->{$property};
|
||||||
|
|
||||||
# use the current value because the update value was undef
|
# use the current value because the update value was undef
|
||||||
unless (defined $value) {
|
unless (defined $value) {
|
||||||
$value = $self->get($property);
|
$value = $self->get($property);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue