diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 528e8e2a5..7e2fc2319 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,7 @@ - fixed: Thingy: field sequence not imported correctly for existing Thingies - fixed: anonymous registration leaves user at blank page - fixed: Thingy: field type 'other thing' does not stay selected + - fixed: Thingy: delete a thing dysfunctions linked things 7.5.9 - fixed: Collaboration System attachments follow site's max size instead of CS's diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 21cabe94a..3ba7be56d 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -579,10 +579,14 @@ sub getFieldValue { elsif ($field->{fieldType} =~ m/^otherThing/x) { my $otherThingId = $field->{fieldType}; $otherThingId =~ s/^otherThing_//x; - ($processedValue) = $self->session->db->quickArray('select ' - .$dbh->quote_identifier('field_'.$field->{fieldInOtherThingId}) - .' from '.$dbh->quote_identifier('Thingy_'.$otherThingId) - .' where thingDataId = ?',[$value]); + my $tableName = 'Thingy_'.$otherThingId; + my ($otherThingTableExists) = $self->session->db->quickArray('show tables like ?',[$tableName]); + if ($otherThingTableExists){ + ($processedValue) = $self->session->db->quickArray('select ' + .$dbh->quote_identifier('field_'.$field->{fieldInOtherThingId}) + .' from '.$dbh->quote_identifier($tableName) + .' where thingDataId = ?',[$value]); + } } elsif ($field->{fieldType} eq "file") { $processedValue = WebGUI::Form::File->new($self->session,{value=>$value})->displayValue(); @@ -609,7 +613,9 @@ sub getFormElement { my $self = shift; my $data = shift; my %param; - my $dbh = $self->session->db->dbh; + my $db = $self->session->db; + my $dbh = $db->dbh; + my $i18n = WebGUI::International->new($self->session,"Asset_Thingy"); $param{name} = "field_".$data->{fieldId}; my $name = $param{name}; @@ -662,16 +668,23 @@ sub getFormElement { my $otherThingId = $data->{fieldType}; $otherThingId =~ s/^otherThing_(.*)/$1/x; $param{fieldType} = "SelectList"; + my $options = (); + my $tableName = 'Thingy_'.$otherThingId; + my ($otherThingTableExists) = $db->quickArray('show tables like ?',[$tableName]); + if ($otherThingTableExists){ + $options = $db->buildHashRef('select thingDataId, ' + .$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId}) + .' from '.$dbh->quote_identifier($tableName)); - my $options = $self->session->db->buildHashRef('select thingDataId, ' - .$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId}) - .' from '.$dbh->quote_identifier('Thingy_'.$otherThingId)); - - my $value = $data->{value} || $data->{defaultValue}; - ($param{value}) = $self->session->db->quickArray('select ' - .$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId}) - .' from '.$dbh->quote_identifier('Thingy_'.$otherThingId) - .' where thingDataId = ?',[$value]); + my $value = $data->{value} || $data->{defaultValue}; + ($param{value}) = $db->quickArray('select ' + .$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId}) + .' from '.$dbh->quote_identifier($tableName) + .' where thingDataId = ?',[$value]); + } + else{ + return $i18n->get('other thing missing message'); + } $param{size} = 1; $param{multiple} = 0; $param{options} = $options; diff --git a/lib/WebGUI/i18n/English/Asset_Thingy.pm b/lib/WebGUI/i18n/English/Asset_Thingy.pm index 742806fa3..7b9f07ca0 100644 --- a/lib/WebGUI/i18n/English/Asset_Thingy.pm +++ b/lib/WebGUI/i18n/English/Asset_Thingy.pm @@ -896,6 +896,11 @@ search has been done.|, message => q|Every asset provides a set of variables to most of its templates based on the internal asset properties. Some of these variables may be useful, others may not.|, lastUpdated => 1164910794, }, + + 'other thing missing message' => { + message => q|The Thing to which this field refers does not exist or has no table.|, + lastUpdated => 1104630516, + }, }; 1;